package control;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.service.ProjectService;
import model.service.RiskIService;
import model.vo.ListVO;
import model.vo.MakindVO;
import model.vo.MasecretVO;
import model.vo.MasecurityVO;
import model.vo.MemberVO;
import model.vo.MraassetVO;
import model.vo.MrainfoVO;
import model.vo.MridentyVO;
import model.vo.MsoaVO;
import model.vo.MtkindVO;
import model.vo.MtlistVO;
import model.vo.MvlistVO;
import model.vo.MvscoreVO;
import model.vo.RiskScenarioVO;
import model.vo.StateReportVO;
import model.vo.TbPublicVO;
import model.vo.TdoaVO;
import model.vo.TreriskVO;
import model.vo.TriskplanVO;
import model.vo.TtriskcalcVO;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import util.ViewUtil;
import util.today;
import com.oreilly.servlet.MultipartRequest;
import com.oreilly.servlet.multipart.DefaultFileRenamePolicy;
public class RiskIController extends MultiActionController {
	//보낼 액션 이름
	private String actionName="riskIAction.do";
	private RiskIService riskIService;
	public void setRiskIService(RiskIService riskIService) {
		this.riskIService = riskIService;
	}
	private ProjectService projectService;
	public void setProjectService(ProjectService projectService) {
		this.projectService = projectService;
	}
	private String savedir;
	private int sizeLimit=10 * 1024 * 1024 ;

	// 마감관리
	public ModelAndView openMagam(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//리스트 값을 얻기전에 base_id의 검색값을 입력
		//List list=riskIService.tbpublicData(base_id);
		//mv.addObject("list",list);
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		List list=riskIService.magam_popup(pro_id);
		mv.addObject("list",list);
		mv.setViewName("openMagam");
		return mv;
	}
	
	//마감 현황 적용 
	public void magam_apply(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		//자산코드의 값을 UTF-8로 인코딩하여 받음
		String pro_id= request.getParameter("pro_id");
		String projectGubun= request.getParameter("gubun");
		String apply= request.getParameter("apply");
		if(apply.equals("Y")){//적용
			projectService.Magam_apply(pro_id, projectGubun);
		}else if(apply.equals("N")){//취소
			projectService.Magam_cancel(pro_id, projectGubun);
		}
		
		JSONObject obj=new JSONObject();
		HttpSession session = request.getSession(false);
		//마감 현황 세션에 저장
		session.setAttribute("magamSession", projectService.proSelectCount(Integer.parseInt(pro_id)));
		//obj.put("gubun", projectGubun);
		//obj.put("apply",apply);
		
		/*
	
		//JSONArray arr=new JSONArray();
		JSONObject childObj=new JSONObject();
		List list=projectService.proSelectCount(Integer.parseInt(pro_id));
		//STATE 값 AJAX로 가지고 나감
		for(int i=0; i<list.size(); i++){
			System.out.println(list.get(i));
			
			
			Map map=(Map) list.get(i);
			Iterator it=map.keySet().iterator();
			while(it.hasNext()){
				String key=it.next().toString();
				System.out.println("key:"+key+" value:"+map.get(key));
				if(key.equals("state")){
					childObj.put("state"+(i+1), map.get(key));
				}
			}
		}
		
		obj.put("list", childObj);
		System.out.println(obj.toString());
		
		String pro_nm="";
		String proDayIndex="";
		if(session.getAttribute("proNm")!=null){
			pro_nm=(String)session.getAttribute("proNm");
			proDayIndex=(String)session.getAttribute("proDayIndex");
		}
		obj.put("pro_id",pro_id);
		obj.put("pro_nm", pro_nm);
		obj.put("proDayIndex", proDayIndex);
		//obj.put("graphList",ViewUtil.makeGraphTableAjax(pro_nm, projectService.proSelectCountVO(Integer.parseInt(pro_id))));
		
		
		//obj.put("magamSession",projectService.proSelectCount(Integer.parseInt(pro_id)));
		 * 
		 */
		obj.put("pro_id",pro_id);
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}	
	//[기준수립]
	//(자산유형목록)
	//자산유형목록 페이지로 이동
	public ModelAndView baseATV(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.baseA();
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		List tlist=riskIService.baseT(pro_id);
		mv.addObject("tlist",tlist);
		List vlist=riskIService.baseV(pro_id);
		mv.addObject("vlist",vlist);
		//페이지 이동(tiles_definition.xml에서 baseA_SL을 읽어 다른곳으로 이동
		mv.setViewName("baseATV_SL");
		return mv;
	}
	//자산유형목록 등록 페이지
	public ModelAndView baseA_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//최대 순번 구해오기
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		List akList=riskIService.tbpublicData("ak_type1");
		mv.addObject("akList",akList);
		mv.setViewName("baseA_SI");
		return mv;
	}
	//자산유형목록 등록
	public ModelAndView baseA_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		TbPublicVO vo=new TbPublicVO();
		//vo에 request값들은 담음
		bind(request, vo);
		vo.setBase_id("ak_type2");
		//system.out.println("자산유형목록 request값: "+vo);
		try{
			riskIService.baseA_insert(vo);
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","baseATV");
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	//자산유형목록  삭제
	public ModelAndView baseA_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String base_lev1[]=request.getParameterValues("check");
		String base_id="ak_type2";
		//체크 박스로 삭제
		if(base_lev1!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<base_lev1.length;i++){
				//system.out.println(base_lev1[i]);
				//삭제
				//int asset_no=Integer.parseInt(assetNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.baseA_delete(base_id,base_lev1[i]);
			}
		}
		//삭제후 list 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","baseATV");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//자산유형목록 수정 페이지로 이동
	public ModelAndView baseA_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		TbPublicVO vo=riskIService.baseA_updatePage(request.getParameter("base_lev2cd"));
		//system.out.println(vo);
		mv.addObject("update","Y");
		List akList=riskIService.tbpublicData("ak_type1");
		mv.addObject("akList",akList);

		TbPublicVO cutNameVo=riskIService.tbpublicDataSelectByBaseLev1("ak_type9", request.getParameter("base_lev2cd"));
		
		mv.addObject("vo", vo);
		mv.addObject("cutNameVo", cutNameVo);
		mv.setViewName("baseA_SI");
		return mv;
	}
	//자산유형목록  수정 
	public ModelAndView baseA_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		TbPublicVO vo=new TbPublicVO();
		//vo에 request값들은 담음
		bind(request, vo);
		vo.setBase_id("ak_type2");
		//system.out.println("자산유형목록 수정값 request값들: "+vo);
		riskIService.baseA_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","baseATV");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//(위협목록)
	//위협목록 페이지로 이동
	public ModelAndView baseT(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.baseT(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		//페이지 이동(tiles_definition.xml에서 baseA_SL을 읽어 다른곳으로 이동
		mv.setViewName("baseT_SL");
		return mv;
	}
	//위협목록 등록 페이지
	public ModelAndView baseT_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//최대 순번 구해오기
		HttpSession session = request.getSession(false);
		//회차 정보
		//List akList=riskIService.tbpublicData("ak_type1");
		//mv.addObject("akList",akList);
		mv.setViewName("baseT_SI");
		return mv;
	}
	//위협목록 등록
	public ModelAndView baseT_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MtkindVO vo=new MtkindVO();
		
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
				
		String reloadPageName=request.getParameter("reloadPageName");
		//vo에 request값들은 담음
		bind(request, vo);
		vo.setPro_id(pro_id);
		//system.out.println("위협목록 request값: "+vo);
		try{
			riskIService.baseT_insert(vo);
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","baseATV");
			mv.addObject("reloadPageName",reloadPageName);
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	//위협목록  삭제
	public ModelAndView baseT_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		
		String reloadPageName=request.getParameter("reloadPageName");
		String base_levAll[]=request.getParameterValues("check1");
		//체크 박스로 삭제
		if(base_levAll!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<base_levAll.length;i++){
				//system.out.println(base_levAll[i]);
				//삭제
				//int asset_no=Integer.parseInt(assetNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.baseT_delete(base_levAll[i],pro_id);
			}
		}
		//삭제후 list 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("reloadPageName",reloadPageName);
		mv.addObject("pageName","baseATV");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//위협목록 수정 페이지로 이동
	public ModelAndView baseT_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MtkindVO vo=riskIService.baseT_updatePage(request.getParameter("base_levAll"),pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		mv.setViewName("baseT_SI");
		return mv;
	}
	//위협목록  수정 
	public ModelAndView baseT_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		
		String reloadPageName=request.getParameter("reloadPageName");
		MtkindVO vo=new MtkindVO();
		//vo에 request값들은 담음
		bind(request, vo);
		vo.setPro_id(pro_id);
		//system.out.println("위협목록 수정값 request값들: "+vo);
		riskIService.baseT_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","baseATV");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	//(취약성목록)
	//취약성목록 페이지로 이동
	public ModelAndView baseV(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.baseV(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		//페이지 이동(tiles_definition.xml에서 baseA_SL을 읽어 다른곳으로 이동
		mv.setViewName("baseV_SL");
		return mv;
	}
	//취약성목록 등록 페이지
	public ModelAndView baseV_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//최대 순번 구해오기
		HttpSession session = request.getSession(false);
		//회차 정보
		//List akList=riskIService.tbpublicData("ak_type1");
		//mv.addObject("akList",akList);
		mv.setViewName("baseV_SI");
		return mv;
	}
	//취약성목록 등록
	public ModelAndView baseV_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String reloadPageName=request.getParameter("reloadPageName");
		MvlistVO vo=new MvlistVO();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//vo에 request값들은 담음
		bind(request, vo);
		vo.setPro_id(pro_id);
		//system.out.println("취약성목록 request값: "+vo);
		try{
			riskIService.baseV_insert(vo);
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","baseATV");
			mv.addObject("reloadPageName",reloadPageName);
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	//취약성목록  삭제
	public ModelAndView baseV_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String ts_cdAll[]=request.getParameterValues("check2");
		String reloadPageName=request.getParameter("reloadPageName");
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//체크 박스로 삭제
		if(ts_cdAll!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<ts_cdAll.length;i++){
				//system.out.println(ts_cdAll[i]);
				//삭제
				//int asset_no=Integer.parseInt(assetNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.baseV_delete(ts_cdAll[i],pro_id);
			}
		}
		//삭제후 list 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","baseATV");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//취약성목록 수정 페이지로 이동
	public ModelAndView baseV_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MvlistVO vo=riskIService.baseV_updatePage(request.getParameter("ts_cdAll"),pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		mv.setViewName("baseV_SI");
		return mv;
	}
	//취약성목록  수정 
	public ModelAndView baseV_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MvlistVO vo=new MvlistVO();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String reloadPageName=request.getParameter("reloadPageName");
		//vo에 request값들은 담음
		bind(request, vo);
		vo.setPro_id(pro_id);
		//system.out.println("취약성목록 수정값 request값들: "+vo);
		riskIService.baseV_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","baseATV");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	
	
	
	//[자산식별]
	//1.자산기준수립
	//(자산유형분류기준)
	//자산유형분류기준 페이지로 이동
	public ModelAndView makind(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.makind(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		//결과를 리스트에 담음
		List scriList=riskIService.masecurity(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("scriList",scriList);
		//결과를 리스트에 담음
		List secreList=riskIService.masecret(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("secreList",secreList);
		//페이지 이동(tiles_definition.xml에서 makind_SL을 읽어 다른곳으로 이동
		mv.setViewName("makind_SL");
		return mv;
	}
	//자산유형분류기준 등록 페이지
	public ModelAndView makind_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//최대 순번 구해오기
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		List list=riskIService.asset_kind(pro_id);
		mv.addObject("list",list);
		mv.setViewName("makind_SI");
		return mv;
	}
	//자산유형분류기준 등록
	public ModelAndView makind_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String base_lev1[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		int proId=Integer.parseInt(pro_id);
		try{
			//체크 박스로 등록
			if(base_lev1!=null){
				//체크된 것들의 value값을 받음
				for(int i=0;i<base_lev1.length;i++){
					int maxNo=riskIService.maxNo("makind_maxNo", proId);
					MakindVO vo=new MakindVO();
					vo=riskIService.asset_kindData(base_lev1[i]);
					vo.setPro_id(proId);
					vo.setAk_id(maxNo);
					//system.out.println(vo);
					//위험식별시나리오 등록
					riskIService.makind_insert(vo);
					//traitem_info 등록
				}
			}
			//삭제후 위험식별시나리오 페이지로 이동.
			mv.setViewName("makind_insertOK");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResultJsp");
		}
		return mv;
	}
	/*
		String pro_id=request.getParameter("pro_id");
		int proId=Integer.parseInt(pro_id);
		try{
			//체크 박스로 등록
			if(hiddenCode!=null){
				//체크된 것들의 value값을 받음
				for(int i=0;i<hiddenCode.length;i++){
					int maxNo=riskIService.maxNo("mridenty_maxNo", proId);
					RiskScenarioVO rvo=new RiskScenarioVO();
					rvo.setPro_id(proId);
					rvo.setHiddenCode(hiddenCode[i]);
					MridentyVO mvo=new MridentyVO();
					mvo=riskIService.makeRiskScenarioData(rvo);
					mvo.setRisk_id(maxNo);
					System.out.println(mvo);
					//위험식별시나리오 등록
					riskIService.mridenty_insert(mvo);
					//traitem_info 등록
				}
			}
			//삭제후 위험식별시나리오 페이지로 이동.
			mv.setViewName("mridenty_insertOK");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResultJsp");
		}
		return mv;
	}
	 * 
	
	*/
	//자산유형분류기준  삭제
	public ModelAndView makind_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String akId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(akId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<akId.length;i++){
				//system.out.println(akId[i]);
				//삭제
				//int asset_no=Integer.parseInt(assetNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.makind_delete(akId[i],pro_id);
			}
		}
		//삭제후 list 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","makind");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//자산유형분류기준  수정 페이지로 이동
	public ModelAndView makind_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		MakindVO vo=riskIService.makind_updatePage(request.getParameter("ak_id"),pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo",vo);
		mv.setViewName("makind_SU");
		return mv;
	}
	//자산유형분류기준  수정 
	public ModelAndView makind_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MakindVO vo=new MakindVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("자산유형분류기준 수정값 request값들: "+vo);
		riskIService.makind_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","makind");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	//(자산보안등급평가기준)
	//자산보안등급평가기준 페이지로 이동
	public ModelAndView masecurity(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.masecurity(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		//페이지 이동(tiles_definition.xml에서 masecurity_SL 읽어 다른곳으로 이동
		mv.setViewName("masecurity_SL");
		return mv;
	}
	//자산보안등급평가기준 등록 페이지
	public ModelAndView masecurity_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//최대 순번 구해오기
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		int maxNo=riskIService.maxNo("masecurity_maxNo",pro_id);
		mv.addObject("maxNo",maxNo);
		mv.setViewName("masecurity_SI");
		return mv;
	}
	//자산보안등급평가기준 등록
	public ModelAndView masecurity_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MasecurityVO vo=new MasecurityVO();
		String reloadPageName=request.getParameter("reloadPageName");
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("자산보안등급평가기준 request값: "+vo);
		try{
			riskIService.masecurity_insert(vo);
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","makind");
			mv.addObject("reloadPageName",reloadPageName);
			mv.setViewName("insertAndDeleteResult");
			
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	//자산보안등급평가기준  삭제
	public ModelAndView masecurity_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String ascuId[]=request.getParameterValues("check1");
		String pro_id=request.getParameter("pro_id");
		String reloadPageName=request.getParameter("reloadPageName");
		//체크 박스로 삭제
		if(ascuId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<ascuId.length;i++){
				//system.out.println(ascuId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.masecurity_delete(ascuId[i],pro_id);
			}
		}
		//삭제후 자산보안등급평가기준 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","makind");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//자산보안등급평가기준 수정 페이지로 이동
	public ModelAndView masecurity_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MasecurityVO vo=riskIService.masecurity_updatePage(request.getParameter("ascu_id"),pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		mv.setViewName("masecurity_SI");
		return mv;
	}
	//자산보안등급평가기준 수정 
	public ModelAndView masecurity_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MasecurityVO vo=new MasecurityVO();
		String reloadPageName=request.getParameter("reloadPageName");
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("자산보안등급평가기준 수정값 request값들: "+vo);
		riskIService.masecurity_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","makind");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	
	
	//(자산기밀등급분류)
	//자산기밀등급분류 페이지로 이동
	public ModelAndView masecret(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.masecret(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		//페이지 이동(tiles_definition.xml에서 masecret_SL 읽어 다른곳으로 이동
		mv.setViewName("masecret_SL");
		return mv;
	}
	//자산기밀등급분류 등록 페이지
	public ModelAndView masecret_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//최대 순번 구해오기
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		int maxNo=riskIService.maxNo("masecret_maxNo",pro_id);
		mv.addObject("maxNo",maxNo);
		mv.setViewName("masecret_SI");
		return mv;
	}
	//자산기밀등급분류 등록
	public ModelAndView masecret_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MasecretVO vo=new MasecretVO();
		String reloadPageName=request.getParameter("reloadPageName");
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("자산기밀등급분류 request값: "+vo);
		try{
			riskIService.masecret_insert(vo);
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","makind");
			mv.addObject("reloadPageName",reloadPageName);
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	//자산기밀등급분류  삭제
	public ModelAndView masecret_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String ascId[]=request.getParameterValues("check2");
		String pro_id=request.getParameter("pro_id");
		String reloadPageName=request.getParameter("reloadPageName");
		//체크 박스로 삭제
		if(ascId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<ascId.length;i++){
				//system.out.println(ascId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.masecret_delete(ascId[i],pro_id);
			}
		}
		//삭제후 자산기밀등급분류 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","makind");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//자산기밀등급분류 수정 페이지로 이동
	public ModelAndView masecret_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MasecretVO vo=riskIService.masecret_updatePage(request.getParameter("asc_id"),pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		mv.setViewName("masecret_SI");
		return mv;
	}
	//자산기밀등급분류 수정 
	public ModelAndView masecret_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MasecretVO vo=new MasecretVO();
		String reloadPageName=request.getParameter("reloadPageName");
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("자산기밀등급분류 수정값 request값들: "+vo);
		riskIService.masecret_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","makind");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	//(분류기준수립)
	//분류기준수립 페이지로 이동
	public ModelAndView mtkind(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String base_lev1=request.getParameter("base_lev1");
		//결과를 리스트에 담음
		List list=null;
		if(base_lev1==null || base_lev1.equals("") || base_lev1.equals("0")){
			HashMap map=new HashMap();
			map.put("pro_id",pro_id);
			//검색
			if(request.getParameter("searchText")!=null){
				//system.out.println(request.getParameter("searchText"));
				map.put("tk_nm2",request.getParameter("searchText"));
			}
			list=riskIService.mtkind(map);
		}else{
			list=riskIService.mtkindSearchBaseLev1(pro_id, base_lev1);
			mv.addObject("base_lev1",base_lev1);
		}
		List distinctList=riskIService.distMtkind(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		mv.addObject("distinctList",distinctList);
		//페이지 이동(tiles_definition.xml에서 mtkind_SL 읽어 다른곳으로 이동
		mv.setViewName("mtkind_SL");
		return mv;
	}
	//분류기준수립 엑셀 다운로드 페이지로 이동
	public ModelAndView exmtkind(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		//검색
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("tk_nm2",request.getParameter("searchText"));
		}
		List list=riskIService.mtkind(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmtkind_SL");
		return mv;
	}
	
	//분류기준수립 등록 페이지
	public ModelAndView mtkind_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//최대 순번 구해오기
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		/*
		int maxNo=riskIService.maxNo("mtkind_maxNo",pro_id);
		mv.addObject("maxNo",maxNo);
		*/
		List distinctList=riskIService.distTbtkind(pro_id);
		mv.addObject("distinctList",distinctList);
		String base_lev1=request.getParameter("base_lev1");
		List list=null;
		if(base_lev1==null || base_lev1.equals("") || base_lev1.equals("0")){
			list=riskIService.tbtkind_data(pro_id);
		}else{
			list=riskIService.tbtkindSearchBaseLev1(pro_id, base_lev1);
			mv.addObject("base_lev1",base_lev1);
		}
		mv.addObject("list",list);
		mv.setViewName("mtkind_SI");
		return mv;
	}
	//분류기준수립 등록
	public ModelAndView mtkind_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String base_levAll[]=request.getParameterValues("check3");
		String pro_id=request.getParameter("pro_id");
		int proId=Integer.parseInt(pro_id);
		try{
			//체크 박스로 등록
			if(base_levAll!=null){
				//체크된 것들의 value값을 받음
				for(int i=0;i<base_levAll.length;i++){
					int maxNo=riskIService.maxNo("mtkind_maxNo", proId);
					MtkindVO vo=new MtkindVO();
					vo=riskIService.tbtkind_InsertData(base_levAll[i], proId);
					vo.setPro_id(proId);
					vo.setTk_id(maxNo);
					//system.out.println(vo);
					//분류기준수립등록
					riskIService.mtkind_insert(vo);
					
					//위협목록 작성 등록
					riskIService.mtlist_insert(vo.getTk_id(),pro_id);
				}
			}
			//삭제후 위험식별시나리오 페이지로 이동.
			mv.setViewName("mtlist_insertOK");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResultJsp");
		}
		return mv;
	}
		/*
		MtkindVO vo=new MtkindVO();
		//vo에 request값들은 담음
		bind(request, vo);
		System.out.println("분류기준수립 request값: "+vo);
		try{
			riskIService.mtkind_insert(vo);
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","mtkind");
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
		*/
	//분류기준수립  삭제
	public ModelAndView mtkind_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String tkId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(tkId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<tkId.length;i++){
				//system.out.println(tkId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.mtkind_delete(tkId[i],pro_id);
			}
		}
		//삭제후 자산기밀등급분류 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mtlist");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//분류기준수립 수정 페이지로 이동
	public ModelAndView mtkind_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MtkindVO vo=riskIService.mtkind_updatePage(request.getParameter("tk_id"), pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		mv.setViewName("mtkind_SU");
		return mv;
	}
	//분류기준수립 수정 
	public ModelAndView mtkind_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MtkindVO vo=new MtkindVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("자산기밀등급분류 수정값 request값들: "+vo);
		riskIService.mtkind_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mtkind");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	// 위협유형 팝업 새창열기
	public ModelAndView openSelectByBaseId(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//리스트 값을 얻기전에 base_id의 검색값을 입력
		String base_id=request.getParameter("base_id");
		List blist=riskIService.tbpublicData(base_id);
		mv.addObject("blist",blist);
		mv.addObject("base_id",base_id);
		mv.setViewName("openSelectByBaseId");
		return mv;
	}
	
	
	//(위협목록작성)
	//위협목록작성 페이지로 이동
	public ModelAndView mtlist(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		
		
		String base_lev1=request.getParameter("base_lev1");
		//결과를 리스트에 담음
		List list=null;
		if(base_lev1==null || base_lev1.equals("") || base_lev1.equals("0")){
			HashMap map=new HashMap();
			map.put("pro_id",pro_id);
			//검색
			if(request.getParameter("searchText")!=null){
				//system.out.println(request.getParameter("searchText"));
				map.put("tk_nm2",request.getParameter("searchText"));
			}
			list=riskIService.mtlist(map);
		}else{
			list=riskIService.mtlistSearchBaseLev1(pro_id, base_lev1);
			mv.addObject("base_lev1",base_lev1);
		}
		List distinctList=riskIService.distMtlist(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		mv.addObject("distinctList",distinctList);

		//페이지 이동(tiles_definition.xml에서 mtlist_SL 읽어 다른곳으로 이동
		mv.setViewName("mtlist_SL");
		return mv;
	}
	
	////위협목록작성 연관자산 팝업창
	public ModelAndView t_akind_popup(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차
		String pro_id=request.getParameter("pro_id");
		//위협코드 1,2,3
		String base_lev1=request.getParameter("base_lev1");
		String base_lev2=request.getParameter("base_lev2");
		String base_lev3=request.getParameter("base_lev3");
		System.out.println(pro_id);
		List list=riskIService.t_akind_popup(pro_id, base_lev1, base_lev2, base_lev3);
		System.out.println(list);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		
		//페이지 이동(팝업창이므로)(jsp-view.xml에서 t_akind_popup 읽어 다른곳으로 이동
		mv.setViewName("t_akind_popup");
		return mv;
	}
	
	
	//위협목록작성 엑셀 다운로드 페이지로 이동
	public ModelAndView exmtlist(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		//검색
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("tk_nm2",request.getParameter("searchText"));
		}
		List list=riskIService.mtlist(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmtlist_SL");
		return mv;
	}
	//위협목록작성 등록 팝업 새창열기
	public ModelAndView openTkList(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		
			 List distinctList=riskIService.distMtkind(pro_id);
			mv.addObject("distinctList",distinctList);
			String base_lev1=request.getParameter("base_lev1");
		//결과를 리스트에 담음
			List list=null;
			if(base_lev1==null || base_lev1.equals("") || base_lev1.equals("0")){
				list=riskIService.openTkList(pro_id);
			}else{
				list=riskIService.openTkListSearchBaseLev1(pro_id, base_lev1);
				mv.addObject("base_lev1",base_lev1);
			}
		
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		//페이지 이동(tiles_definition.xml에서 masecurity_SL 읽어 다른곳으로 이동
		mv.setViewName("openTkList");
		return mv;
	}
	//위협목록작성  등록
	public ModelAndView mtlist_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String tkId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 등록
		try{
			if(tkId!=null){
				//체크된 것들의 value값을 받음
				for(int i=0;i<tkId.length;i++){
					//system.out.println(tkId[i]);
					//등록
					//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
					//순번은 service단에서 받아서씀
					riskIService.mtlist_insert(Integer.parseInt(tkId[i]),pro_id);
				}
			}
			mv.setViewName("mtlist_insertOK");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResultJsp");
		}
		return mv;
	}
	//위협목록작성  삭제
	public ModelAndView mtlist_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String tlId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(tlId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<tlId.length;i++){
				//system.out.println(tlId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.mtlist_delete(tlId[i],pro_id);
			}
		}
		//삭제후 위협목록작성 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mtlist");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//위협목록작성 수정 페이지로 이동
	public ModelAndView mtlist_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MtlistVO vo=riskIService.mtlist_updatePage(request.getParameter("tl_id"), pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		mv.setViewName("mtlist_SI");
		return mv;
	}
	//위협목록작성 수정 
	public ModelAndView mtlist_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MtlistVO vo=new MtlistVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("자산기밀등급분류 수정값 request값들: "+vo);
		riskIService.mtlist_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mtlist");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	
	
	
	
	//2.자산식별및평가
	//(RA정보자산식별)
	//RA정보자산식별 페이지로 이동
	public ModelAndView mrainfo(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//RA정보 식별
		HashMap map=new HashMap();
			map.put("pro_id",pro_id);
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("rainfo_nm",request.getParameter("searchText"));
		}
		
		List list=riskIService.mrainfo(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		
		//RA정보-컨테이너현황
		//결과를 리스트에 담음
		List alist=riskIService.makind(pro_id);
		//HashMap mapx=new HashMap();
		ArrayList<MakindVO> listMap=riskIService.makindMap(pro_id);
		//mapx.put("listMap",listMap);
		//mapx.put("pro_id",pro_id);
		//system.out.println(list);
		//system.out.println(listMap);
		//List metList=riskIService.atmetrix(pro_id, map);
		List metList=riskIService.mastate(pro_id, listMap);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("alist",alist);
		//system.out.println("나온값:"+metList);
		mv.addObject("metList",metList);
		
		
		
		
		
		//RA정보평가
		//결과를 리스트에 담음
		//List list=riskIService.mrainfop(pro_id);
		HashMap mapz=new HashMap();
		mapz.put("pro_id",pro_id);
		String searchText="";
		if(request.getParameter("searchText1")!=null){
			//system.out.println(request.getParameter("searchText"));
			mapz.put("rainfo_nm",request.getParameter("searchText1"));
			searchText=request.getParameter("searchText1");
		}
		
		List plist=riskIService.mrainfop(mapz);
		
		mv.addObject("pyungCount",riskIService.pyungCount(pro_id,"trainfo","ascu_level",searchText));
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("plist",plist);
		
		//페이지 이동(tiles_definition.xml에서 mrainfo_SL 읽어 다른곳으로 이동
		mv.setViewName("mrainfo_SL");
		
		//컨테이너 호출값 예
		//List contList2=riskIService.tracont2_list(pro_id);
		//List contList1=riskIService.tracont1_list("proId",request.getParameter("rainfo_id"));
		//List contList1=riskIService.tracont1_list("1","q123");
		//TracontVO tvo=riskIService.tracont1_listByRacontNm("1", "q123", "하드웨어컨테이너");
		//mv.addObject("contList2",contList2);
		//System.out.println(contList2);
		//mv.addObject("contList1",contList1);
		//System.out.println(contList1);
		//mv.addObject("tvo",tvo);
		//System.out.println(tvo);
		//예제 끝
		return mv;
	}
	
	//RA정보자산식별엑셀 다운로드 페이지로 이동
	public ModelAndView exmrainfo(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("rainfo_nm",request.getParameter("searchText"));
		}
		List list=riskIService.mrainfo(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmrainfo_SL");
		return mv;
	}
	//RA정보코드 유효성 검사(Ajax)
	public void searchRainfoId(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		//자산코드의 값을 UTF-8로 인코딩하여 받음
		String rainfo_id= request.getParameter("rainfo_id");
		String pro_id=request.getParameter("pro_id");
		//system.out.println(rainfo_id);
		JSONObject obj=new JSONObject();
			boolean rainfo_idFlag = riskIService.searchRainfoId(rainfo_id,pro_id);
			if (rainfo_idFlag) {// a_cd가 있으면
				obj.put("rainfo_idFlag", "N");
				} else {// a_cd가  없으면
				obj.put("rainfo_idFlag", "Y");
			}
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}	
	
	public void onloadTracont2List(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String state="N";
		if(request.getParameter("state")=="" && request.getParameter("state")==null){}else{
		state=request.getParameter("state");
		}
		List list=riskIService.tracont2_list(pro_id);
		//system.out.println(list);
		JSONObject obj=new JSONObject();
		obj.put("contList2",ViewUtil.Tracont2List(list, state));
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	
	
	public void changeTracont1List(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String pro_id=request.getParameter("pro_id");
		String rainfo_id=request.getParameter("rainfo_id");
		String rainfo_nm=request.getParameter("rainfo_nm");
		List list=riskIService.tracont1_list(pro_id,rainfo_id);
		//system.out.println(list);
		JSONObject obj=new JSONObject();
		String state="N";
		if(request.getParameter("state")=="" && request.getParameter("state")==null){}else{
		state=request.getParameter("state");
		}
		obj.put("contList1",ViewUtil.changeTracont1List(list, state));
		obj.put("rainfo_id",rainfo_id);
		obj.put("rainfo_nm",rainfo_nm);
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	
	//RA컨테이너1 등록
	public void tracont1_insertAjax(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String proId=request.getParameter("pro_id");
		String rainfo_id=request.getParameter("rainfo_id");
		String base_lev1=request.getParameter("base_lev1");
		String racont_nm=request.getParameter("racont_nm");
		JSONObject obj=new JSONObject();
		String state="N";
		if(request.getParameter("state")=="" && request.getParameter("state")==null){}else{
		state=request.getParameter("state");
		}
		boolean useTracont2Flag = riskIService.searchUseTracont2(proId, base_lev1, racont_nm);
		if (useTracont2Flag) {// a_cd가 있으면
			obj.put("useTracont2Flag", "Y");
			} else {// a_cd가  없으면
			try{
				riskIService.tracont1_insert(proId, rainfo_id, base_lev1, racont_nm);
				obj.put("insertFlag","Y");
			}catch (SQLException e) {//SQL에러시
				obj.put("insertFlag","N");
			}
			List list=riskIService.tracont1_list(proId,rainfo_id);
			//system.out.println(list);
			obj.put("contList1",ViewUtil.changeTracont1List(list, state));
		}
		
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
		
	}
	
	//RA컨테이너1 삭제
	public void tracont1_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String proId=request.getParameter("pro_id");
		String rainfo_id=request.getParameter("rainfo_id");
		String racont_nm=request.getParameter("racont_nm");
		String state="N";
		if(request.getParameter("state")=="" && request.getParameter("state")==null){}else{
		state=request.getParameter("state");
		}
		JSONObject obj=new JSONObject();
		
			riskIService.tracont1_delete(proId, rainfo_id, racont_nm);
		
		List list=riskIService.tracont1_list(proId,rainfo_id);
		//system.out.println(list);
		obj.put("contList1",ViewUtil.changeTracont1List(list,state));
		
		
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
		
	}
	//RA컨테이너2 등록
	public void tracont2_insertAjax(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String proId=request.getParameter("pro_id");
		String rainfo_id=request.getParameter("rainfo_id");
		String base_lev1=request.getParameter("base_lev1");
		String racont_nm=request.getParameter("racont_nm");
		String state="N";
		if(request.getParameter("state")=="" && request.getParameter("state")==null){}else{
		state=request.getParameter("state");
		}
		JSONObject obj=new JSONObject();
		try{
			riskIService.tracont2_insert(proId, base_lev1, racont_nm);
			riskIService.tracont1_deleteByRacontNm(proId, racont_nm);
			obj.put("insertFlag","Y");
		}catch (SQLException e) {//SQL에러시
			//system.out.println(e.getMessage());
			obj.put("insertFlag","N");
		}
		
		List list=riskIService.tracont1_list(proId,rainfo_id);
		//system.out.println(list);
		obj.put("contList1",ViewUtil.changeTracont1List(list,state));
		List list1=riskIService.tracont2_list(Integer.parseInt(proId));
		obj.put("contList2",ViewUtil.Tracont2List(list1,state));
		
		
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
		
	}
	
	//RA컨테이너2 삭제
	public void tracont2_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String proId=request.getParameter("pro_id");
		String racont_nm=request.getParameter("racont_nm");
		String state="N";
		if(request.getParameter("state")=="" && request.getParameter("state")==null){}else{
		state=request.getParameter("state");
		}
		JSONObject obj=new JSONObject();
		
			riskIService.tracont2_delete(proId, racont_nm);

		List list=riskIService.tracont2_list(Integer.parseInt(proId));
		//system.out.println(list);
		obj.put("contList2",ViewUtil.Tracont2List(list, state));
		
		
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
		
	}
	/*
	//컨테이너 정보 변경
	public void changeCon(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String rainfo_id= new String(request.getParameter("rainfo_id").getBytes("8859_1"),"UTF-8");
		String pro_id=request.getParameter("pro_id");
		List list=riskIService.changeCon(pro_id,rainfo_id);
		System.out.println(list);
		JSONObject obj=new JSONObject();
		if(list.size()!=0){
			obj.put("list",ViewUtil.createChangeConTable(list));
		}else{
			obj.put("flag","N");
		}
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	*/
	//RA정보자산식별 등록 페이지
	public ModelAndView mrainfo_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		mv.setViewName("mrainfo_SI");
		return mv;
	}
	//RA정보자산식별 등록
	public ModelAndView mrainfo_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MrainfoVO vo=new MrainfoVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("RA정보자산식별 request값: "+vo);
		try{
			riskIService.mrainfo_insert(vo);
			//등록후 list 페이지로 이동
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","mrainfo");
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	/*
	//컨테이너 테이블 생성(mrainfo_SI.jsp페이지)
	public void makeTracontTableAjax(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String rainfo_id=request.getParameter("rainfo_id");
		String proId=request.getParameter("pro_id");
		int pro_id=Integer.parseInt(proId);
		List maList=riskIService.makind(pro_id);
		List conList=riskIService.changeCon(proId,rainfo_id);
		//System.out.println(maList);
		//System.out.println(conList);
		JSONObject obj=new JSONObject();
		if(conList.size()!=0){
			obj.put("list",ViewUtil.makeTracontTableAjax(conList));
		}else{
			obj.put("flag","N");
		}
		/*
		if(maList.size()!=0){
			obj.put("list",ViewUtil.makeTracontTableAjax(maList,conList));
		}else{
			obj.put("flag","N");
		}
		*/
	/*
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	*/
	/*
	//컨테이너 등록 테이블 생성(mrainfo_SI.jsp페이지)
	public void tracontInsertTableAjax(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String rainfo_id=request.getParameter("rainfo_id");
		String racontId=request.getParameter("racont_id");
		String proId=request.getParameter("pro_id");
		String akId=request.getParameter("ak_id");
		int pro_id=Integer.parseInt(proId);
		JSONObject obj=new JSONObject();
		TracontVO tvo=riskIService.tracontTable(rainfo_id,racontId,akId,proId);
		System.out.println(tvo);
		if(tvo==null){
			MakindVO mvo=riskIService.makind_updatePage(akId,pro_id);
			int racont_id=riskIService.tracont_maxNo(rainfo_id,proId);
			System.out.println("mvo:"+mvo);
			obj.put("ak_id", mvo.getAk_id());
			obj.put("ak_standard", mvo.getAk_standard());
			//obj.put("ak_type", mvo.getAk_type());
			obj.put("racont_id", racont_id);
		}else{
			obj.put("ak_id", tvo.getAk_id());
			obj.put("ak_standard", tvo.getAk_standard());
			obj.put("ak_type", tvo.getAk_type());
			obj.put("racont_id", tvo.getRacont_id());
			obj.put("racont_nm",tvo.getRacont_nm());
		}
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	//컨테이너  삭제
	public ModelAndView mrainfoCon_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String rainfoAndRacontId[]=request.getParameterValues("checkCon");
		String pro_id=request.getParameter("conPro_id");
		System.out.println(pro_id);
		//체크 박스로 삭제
		if(rainfoAndRacontId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<rainfoAndRacontId.length;i++){
				//System.out.println(rainfoAndRacontId[i]);
				//삭제
				String[] str=rainfoAndRacontId[i].split("\\|");
				String rainfoId=str[0];
				String racontId=str[1];
				//System.out.println("rainfoId: "+rainfoId);
				//System.out.println("racontId: "+racontId);
				riskIService.mrainfoCon_delete(rainfoId,racontId,pro_id);
			}
		}
		//삭제후 RA정보목록작성 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mrainfo");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	*/
	//RA정보자산식별  삭제
	public ModelAndView mrainfo_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String rainfoId[]=request.getParameterValues("check1");
		String pro_id=request.getParameter("pro_id");
		//System.out.println(pro_id);
		//체크 박스로 삭제
		if(rainfoId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<rainfoId.length;i++){
				//System.out.println(rainfoId[i]);
				//삭제
				//System.out.println("rainfoId: "+rainfoId);
				//System.out.println("racontId: "+racontId);
				riskIService.mrainfo_delete(rainfoId[i],pro_id);
			}
		}
		//삭제후 RA정보목록작성 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mrainfo");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	/*
	//RA정보자산식별 등록
	public void tracont_insertAjax(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		TracontVO vo=new TracontVO();
		//vo에 request값들은 담음
		bind(request, vo);
		System.out.println("자산기밀등급분류 request값: "+vo);
		JSONObject obj=new JSONObject();
		try{
			riskIService.tracont_insert(vo);
			obj.put("insertFlag","Y");
		}catch (SQLException e) {//SQL에러시
			riskIService.tracont_update(vo);
			obj.put("updateFlag","Y");
		}
		List maList=riskIService.makind(vo.getPro_id());
		List conList=riskIService.changeCon(Integer.toString(vo.getPro_id()),vo.getRainfo_id());
			if(conList.size()!=0){
				obj.put("list",ViewUtil.makeTracontTableAjax(conList));
			}else{
				obj.put("flag","N");
			}
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	*/
	//RA정보자산식별 수정 페이지로 이동
	public ModelAndView mrainfo_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		//int tdNum=4;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MrainfoVO vo=riskIService.mrainfo_updatePage(request.getParameter("rainfo_id"), pro_id);
		/*//컨테이너값 테이블
		if(vo!=null){
			List maList=riskIService.makind(pro_id);
			List conList=riskIService.changeCon(Integer.toString(pro_id),vo.getRainfo_id());
			
			if(conList.size()!=0){
				mv.addObject("list",ViewUtil.makeTracontTableAjax(conList));
			}else{
				mv.addObject("list",ViewUtil.noDataTable(tdNum));
			}
			
		}else{
			mv.addObject("list",ViewUtil.noDataTable(tdNum));
		}
		*/
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		mv.setViewName("mrainfo_SI");
		return mv;
	}
	//RA정보자산식별 수정 
	public ModelAndView mrainfo_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MrainfoVO vo=new MrainfoVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("RA정보자산식별 수정값 request값들: "+vo);
		riskIService.mrainfo_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mrainfo");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	//컨테이너 리스트 팝업 새창열기
	public ModelAndView openConList(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//String rainfo_id=request.getParameter("rainfo_id");
		//결과를 리스트에 담음
		List list=riskIService.makind(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//mv.addObject("rainfo_id",rainfo_id);
		mv.addObject("list",list);
		mv.setViewName("openConList");
		return mv;
	}
	//컨테이너 등록 테이블 생성(mrainfo_SI.jsp페이지)
	public void tracontChoiceDataAjax(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		//String rainfo_id=request.getParameter("rainfo_id");
		String proId=request.getParameter("pro_id");
		String akId=request.getParameter("ak_id");
		int pro_id=Integer.parseInt(proId);
		JSONObject obj=new JSONObject();
			MakindVO mvo=riskIService.makind_updatePage(akId,pro_id);
			//int racont_id=riskIService.tracont_maxNo(rainfo_id,proId);
			//system.out.println("mvo:"+mvo);
			//obj.put("ak_id", mvo.getAk_id());
			obj.put("base_lev1", mvo.getBase_lev1());
			obj.put("ak_nm2", mvo.getAk_nm2());
			//obj.put("ak_type", mvo.getAk_type());
			//obj.put("racont_id", racont_id);
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	
	
	//(RA정보자산평가)
	//RA정보자산평가 페이지로 이동
	public ModelAndView mrainfop(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		//List list=riskIService.mrainfop(pro_id);
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		String searchText="";
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("rainfo_nm",request.getParameter("searchText"));
			searchText=request.getParameter("searchText");
		}
		
		List list=riskIService.mrainfop(map);
		mv.addObject("pyungCount",riskIService.pyungCount(pro_id,"trainfo","ascu_level", searchText));
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		mv.setViewName("mrainfop_SL");
		return mv;
	}
	
	
	//RA정보자산평가 엑셀 다운로드 페이지로 이동
	public ModelAndView exmrainfop(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		//검색
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("rainfo_nm",request.getParameter("searchText"));
		}
		List list=riskIService.mrainfop(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmrainfop_SL");
		return mv;
	}
	//RA정보자산평가 수정 페이지로 이동
	public ModelAndView mrainfop_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MrainfoVO vo=riskIService.mrainfop_updatePage(request.getParameter("rainfo_id"), pro_id);
		List ascList=riskIService.secretLevel(pro_id);
		List scoreList=riskIService.tbpublicData("ak_score");
		mv.addObject("scoreList",scoreList);
		mv.addObject("vo", vo);
		mv.addObject("ascList",ascList);
		mv.addObject("update","Y");
		mv.setViewName("mrainfop_SI");
		return mv;
	}
	//자산 등급 검사(Ajax)
	public void autoAscuLevelSelect(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		//float 타입으로 캐스팅
		int sum=Integer.parseInt(request.getParameter("sum"));
		int pro_id=Integer.parseInt(request.getParameter("pro_id"));
		JSONObject obj=new JSONObject();
		//자산 중요도 평가 정보를 부름
		List ascuList=riskIService.masecurity(pro_id);
		if(ascuList.size()!=0){
			for (int i = 0;i<ascuList.size();i++){
				MasecurityVO vo=(MasecurityVO)ascuList.get(i);
				int ascuScnt=vo.getAscu_scnt();
				int ascuLcnt=vo.getAscu_lcnt();
				//받아온 데이터가 시작보다 크거나 같고, 나중값+1 보다 작을때
				//if(sScore<=assetScore && assetScore<(lScore+1)){
				if(ascuScnt<=sum && sum<(ascuLcnt+1)){
					//System.out.println(vo.getImpo_kind());
					//자산등급을 적어줌
					obj.put("ascu_id", vo.getAscu_id());
					obj.put("ascu_level",vo.getAscu_level());
				}
			}
		}else{
			obj.put("ascu_id","N");
			obj.put("ascu_level","N");
		}
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}	
	//RA정보자산평가 수정 
	public ModelAndView mrainfop_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MrainfoVO vo=new MrainfoVO();
		String reloadPageName=request.getParameter("reloadPageName");
		//vo에 request값들은 담음
		bind(request, vo);
		//asc_level값 세팅
		int asc_id=vo.getAsc_id();
		List<MasecretVO> ascList=riskIService.secretLevel(vo.getPro_id());
		for(MasecretVO masecVO:ascList){
			if(masecVO.getAsc_id()==asc_id){
				vo.setAsc_level(masecVO.getAsc_level());
			}
		}
		//
		//system.out.println("정보자산평가 수정값 request값들: "+vo);
		riskIService.mrainfop_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mrainfo");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//RA정보자산평가  삭제
	public ModelAndView mrainfop_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String rainfoId[]=request.getParameterValues("check3");
		String pro_id=request.getParameter("pro_id");
		String reloadPageName=request.getParameter("reloadPageName");
		//system.out.println(pro_id);
		//체크 박스로 삭제
		if(rainfoId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<rainfoId.length;i++){
				//System.out.println(rainfoId[i]);
				//삭제
				//System.out.println("rainfoId: "+rainfoId);
				//System.out.println("racontId: "+racontId);
				riskIService.mrainfo_delete(rainfoId[i],pro_id);
			}
		}
		//삭제후 RA정보자산평가 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mrainfo");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	//(자산현황)
	//자산현황 페이지로 이동
	public ModelAndView mastate(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.makind(pro_id);
		HashMap map=new HashMap();
		ArrayList<MakindVO> listMap=riskIService.makindMap(pro_id);
		map.put("listMap",listMap);
		map.put("pro_id",pro_id);
		//system.out.println(list);
		//system.out.println(listMap);
		//List metList=riskIService.atmetrix(pro_id, map);
		List metList=riskIService.mastate(pro_id, listMap);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		//system.out.println("나온값:"+metList);
		mv.addObject("metList",metList);
		
		//페이지 이동(tiles_definition.xml에서 atmetrix_SL을 읽어 다른곳으로 이동
		mv.setViewName("mastate_SL");
		return mv;
	}
	
	
	//자산현황 등록 페이지로 이동
	public ModelAndView mastate_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		
		//컨테이너 리스트
		List traList=riskIService.tracont_list(pro_id);
		
		mv.addObject("traList",traList);
		
		//자산유형 리스트
		List makList=riskIService.makind(pro_id);
		
		mv.addObject("makList",makList);
		
		
		//RA정보 식별 리스트
		HashMap map=new HashMap();
			map.put("pro_id",pro_id);
		List mraList=riskIService.mrainfo(map);
		
		mv.addObject("mraList",mraList);
		
		
		//페이지 이동(tiles_definition.xml에서 atmetrix_SL을 읽어 다른곳으로 이동
		mv.setViewName("mastate_SI");
		return mv;
	}
	//자산현황 등록 
	public ModelAndView mastate_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		
		//컨테이너 명
		String racont_nm=request.getParameter("racont_nm");
		//자산유형
		String base_lev1=request.getParameter("check1");
		//정보명칭
		String rainfo_id[]=request.getParameterValues("check2");
		String pro_id=request.getParameter("pro_id");
		
		//RA정보 식별 리스트
		HashMap map=new HashMap();
			map.put("pro_id",Integer.parseInt(pro_id));
		List mraList=riskIService.mrainfo(map);

		
		// 컨테이너에 컨테이너 유무 조회		
		List list=riskIService.contSearch(pro_id, racont_nm, base_lev1);
		//컨테이너에 값이 존재하지 않으면 
		if(list.size()==0){//insert
			if(mraList.size()==rainfo_id.length){//정보선택한 수와 정보 명칭 수가 같으면 공통으로 insert
				riskIService.tracont2_insert(pro_id, base_lev1, racont_nm);
			}else{//정보선택한 수와 정보 명칭 수가 다르면 개별 insert
				for(int i=0;i<rainfo_id.length;i++){
					riskIService.tracont1_insert(pro_id, rainfo_id[i],  base_lev1, racont_nm);
				}
			}
		}else{//update
			riskIService.tracont1_deleteByRacontNm(pro_id, racont_nm);
			riskIService.tracont2_delete(pro_id, racont_nm);
			if(mraList.size()==rainfo_id.length){//정보선택한 수와 정보 명칭 수가 같으면 공통으로 update
				riskIService.tracont2_insert(pro_id, base_lev1, racont_nm);
			}else{//정보선택한 수와 정보 명칭 수가 다르면 개별 update
				for(int i=0;i<rainfo_id.length;i++){
					riskIService.tracont1_insert(pro_id, rainfo_id[i],  base_lev1, racont_nm);
				}
			}
		}
		//system.out.println(pro_id);
			//체크된 것들의 value값을 받음
		//삭제후 RA정보자산평가 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mastate_insertPage");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	//RA정보식별  삭제
	public ModelAndView mastate_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String racont_nm[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//system.out.println(pro_id);
		//체크 박스로 삭제
		if(racont_nm!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<racont_nm.length;i++){
				riskIService.tracont1_deleteByRacontNm(pro_id, racont_nm[i]);
				riskIService.tracont2_delete(pro_id, racont_nm[i]);
			}
		}
		//삭제후 RA정보식별 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mastate_insertPage");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	//(RA자산식별)
	//RA자산식별 페이지로 이동
	public ModelAndView mraasset(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//RA자산 식별
		//결과를 리스트에 담음
		//List list=riskIService.mraasset(pro_id);
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		//검색
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("raitem_nm",request.getParameter("searchText"));
		}
		List list=riskIService.mraasset(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		
		
		//RA자산 평가
		//결과를 리스트에 담음
		HashMap mapz=new HashMap();
		mapz.put("pro_id",pro_id);
		//검색
		if(request.getParameter("searchText1")!=null){
			//system.out.println(request.getParameter("searchText"));
			mapz.put("raitem_nm",request.getParameter("searchText1"));
		}
		List plist=riskIService.mraassetp(mapz);

		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("plist",plist);
		
		mv.setViewName("mraasset_SL");
		return mv;
	}
	
	//RA정보식별 엑셀 다운로드 페이지로 이동
	public ModelAndView exmraasset(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		//검색
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("raitem_nm",request.getParameter("searchText"));
		}
		List list=riskIService.mraasset(map);

		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmraasset_SL");
		return mv;
	}
	
	//RA정보식별 등록 페이지
	public ModelAndView mraasset_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		List list=riskIService.distinctRacontNmAndCount(pro_id);
		//system.out.println(list);
		//List list2=riskIService.mappingInfoByTracont(pro_id,racont_nm);
		int totalRacontCount=riskIService.totalRacontCount(pro_id);
		mv.addObject("totalRacontCount",totalRacontCount);
		mv.addObject("list",list);
		//mv.addObject("list2",list2);
		mv.setViewName("mraasset_SI");
		return mv;
	}
	
	
	
	//RA정보식별  등록
	public ModelAndView mraasset_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String raitemNmAndGub[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		int proId=Integer.parseInt(pro_id);
		try{
			//체크 박스로 삭제
			if(raitemNmAndGub!=null){
				//체크된 것들의 value값을 받음
				for(int i=0;i<raitemNmAndGub.length;i++){
					String[] str=raitemNmAndGub[i].split("\\|");
					String raitemNm=str[0];
					//system.out.println("raitemNm : "+raitemNm);
					String gub=str[1];
					//system.out.println("gub : "+gub);
					MraassetVO ivo=riskIService.mraasset_insertData(pro_id,raitemNm,gub);
					//system.out.println("ivo : "+ivo);
					List list=riskIService.mraasset_memoData(proId,raitemNm,gub);
					//system.out.println("list : "+list);
					String raitem_id=riskIService.mraasset_maxNo(proId,ivo.getBase_lev1());
					//system.out.println("raitem_id : "+raitem_id);
					ivo.setPro_id(proId);
					ivo.setRaitem_id(raitem_id);
					String c_memo="";
					String i_memo="";
					String a_memo="";
					for (int j = 0;j<list.size();j++){
						MrainfoVO vo=(MrainfoVO)list.get(j);
						//system.out.println(vo);
						System.out.println(vo.getRainfo_id());
						
						if(vo.getC_memo()!=null || vo.getC_memo().equals("")){
							c_memo=vo.getC_memo()+"\r\n"+c_memo;
						}
						if(vo.getI_memo()!=null || vo.getI_memo().equals("")){
							i_memo=vo.getI_memo()+"\r\n"+i_memo;
						}
						if(vo.getA_memo()!=null || vo.getA_memo().equals("")){
							a_memo=vo.getA_memo()+"\r\n"+a_memo;
						}
					}
					ivo.setC_memo(c_memo);
					ivo.setI_memo(i_memo);
					ivo.setA_memo(a_memo);
					//system.out.println("c_memo : "+c_memo);
					//system.out.println("i_memo : "+i_memo);
					//system.out.println("a_memo : "+a_memo);
					List ascuList=riskIService.masecurity(proId);
					//system.out.println("ascuList : "+ascuList);
					if(ascuList.size()!=0){
						for (int k = 0;k<ascuList.size();k++){
							MasecurityVO vo=(MasecurityVO)ascuList.get(k);
							int ascuScnt=vo.getAscu_scnt();
							int ascuLcnt=vo.getAscu_lcnt();
							//받아온 데이터가 시작보다 크거나 같고, 나중값+1 보다 작을때
							//if(sScore<=assetScore && assetScore<(lScore+1)){
							if(ascuScnt<=ivo.getT_score() && ivo.getT_score()<(ascuLcnt+1)){
								//System.out.println(vo.getImpo_kind());
								//자산등급을 적어줌
								ivo.setAscu_id(vo.getAscu_id());
								ivo.setAscu_level(vo.getAscu_level());
							}
						}
					}
					String asc_level=riskIService.ascLevel(ivo);
					ivo.setAsc_level(asc_level);
					//system.out.println("ivo최종:"+ivo);
					//정보식별 등록
					riskIService.mraasset_insert(ivo);
					//traitem_info 등록
					for (int l = 0;l<list.size();l++){
						MrainfoVO vo=(MrainfoVO)list.get(l);
						//system.out.println("rainfo id : "+vo.getRainfo_id());
						riskIService.traitemInfoInsert(proId, raitem_id, vo.getRainfo_id());
					}
					
				}
			}
			//삭제후 자산기밀등급분류 페이지로 이동
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","mraasset");
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			//system.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	//컨테이너에 매핑되어있는 ra정보테이블
	@SuppressWarnings("unchecked")
	public void changeMappingTable(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String raitem_nm= request.getParameter("raitem_nm");
		int pro_id=Integer.parseInt(request.getParameter("pro_id"));
		String gub= request.getParameter("gub");
		List list=riskIService.mappingInfoByRaitemNm(pro_id,raitem_nm,gub);
		int totalMCount=riskIService.totalMCount(pro_id,raitem_nm,gub);
		//system.out.println(list);
		JSONObject obj=new JSONObject();
		obj.put("list",ViewUtil.changeMappingTable(list));
		obj.put("totalMCount",totalMCount);
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	//연관 정보 갯수 새창열기
	public ModelAndView openMappingCount(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String raitem_id=request.getParameter("raitem_id");
		//결과를 리스트에 담음
		List list=riskIService.mappingInfoByRaitemId(pro_id,raitem_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("raitem_id",raitem_id);
		mv.addObject("list",list);
		mv.setViewName("openMappingCount");
		return mv;
	}
	//평가기준수립 수정페이지
	public ModelAndView mraasset_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		String raitem_id=request.getParameter("raitem_id");
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MraassetVO vo=riskIService.mraasset_updatePage(pro_id, raitem_id);
		List list=riskIService.mappingInfoByRaitemId(pro_id,raitem_id);
		
		
		List ascList=riskIService.secretLevel(pro_id);
		List scoreList=riskIService.tbpublicData("ak_score");
		mv.addObject("scoreList",scoreList);
		mv.addObject("ascList",ascList);
		
		mv.addObject("list",list);
		mv.addObject("update","Y");
		//system.out.println(vo);
		mv.addObject("vo", vo);
		mv.setViewName("mraasset_SU");
		
		
		
		return mv;
	}
	//평가기준수립  수정 
	public ModelAndView mraasset_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MraassetVO vo=new MraassetVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("평가기준수립 수정값 request값들: "+vo);
		riskIService.mraasset_update(vo);
		
		//자산평가 업데이트
		int asc_id=vo.getAsc_id();
		List<MasecretVO> ascList=riskIService.secretLevel(vo.getPro_id());
		for(MasecretVO masecVO:ascList){
			if(masecVO.getAsc_id()==asc_id){
				vo.setAsc_level(masecVO.getAsc_level());
			}
		}
		//
		//system.out.println("RA정보평가 수정값 request값들: "+vo);
		riskIService.mraassetp_update(vo);
		
		
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mraasset");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//RA정보식별  삭제
	public ModelAndView mraasset_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String raitemId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//system.out.println(pro_id);
		//체크 박스로 삭제
		if(raitemId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<raitemId.length;i++){
				//System.out.println(rainfoId[i]);
				//삭제
				//System.out.println("rainfoId: "+rainfoId);
				//System.out.println("racontId: "+racontId);
				riskIService.mraasset_delete(raitemId[i],pro_id);
			}
		}
		//삭제후 RA정보식별 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mraasset");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	//(RA자산평가)
	//RA자산평가 페이지로 이동
	public ModelAndView mraassetp(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		//검색
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("raitem_nm",request.getParameter("searchText"));
		}
		List list=riskIService.mraassetp(map);

		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		mv.setViewName("mraassetp_SL");
		return mv;
	}
	//(RA자산평가)
	//RA자산평가 엑셀 다운로드 페이지로 이동
	public ModelAndView exmraassetp(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		//검색
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("raitem_nm",request.getParameter("searchText"));
		}
		List list=riskIService.mraassetp(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmraassetp_SL");
		return mv;
	}
	//RA정보평가 수정페이지
	public ModelAndView mraassetp_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		String raitem_id=request.getParameter("raitem_id");
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MraassetVO vo=riskIService.mraassetp_updatePage(pro_id, raitem_id);
		List ascList=riskIService.secretLevel(pro_id);
		List scoreList=riskIService.tbpublicData("ak_score");
		mv.addObject("scoreList",scoreList);
		mv.addObject("ascList",ascList);
		mv.addObject("update","Y");
		//system.out.println(vo);
		mv.addObject("vo", vo);
		mv.setViewName("mraassetp_SI");
		return mv;
	}
	//RA정보평가 수정 
	public ModelAndView mraassetp_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MraassetVO vo=new MraassetVO();
		String reloadPageName=request.getParameter("reloadPageName");
		//vo에 request값들은 담음
		bind(request, vo);
		//asc_level값 세팅
		int asc_id=vo.getAsc_id();
		List<MasecretVO> ascList=riskIService.secretLevel(vo.getPro_id());
		for(MasecretVO masecVO:ascList){
			if(masecVO.getAsc_id()==asc_id){
				vo.setAsc_level(masecVO.getAsc_level());
			}
		}
		//
		//system.out.println("RA정보평가 수정값 request값들: "+vo);
		riskIService.mraassetp_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mraasset");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//RA정보식별  삭제
	public ModelAndView mraassetp_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String raitemId[]=request.getParameterValues("check1");
		String pro_id=request.getParameter("pro_id");
		String reloadPageName=request.getParameter("reloadPageName");
		//system.out.println(pro_id);
		//체크 박스로 삭제
		if(raitemId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<raitemId.length;i++){
				////system.out.println(rainfoId[i]);
				//삭제
				//System.out.println("rainfoId: "+rainfoId);
				//System.out.println("racontId: "+racontId);
				riskIService.mraasset_delete(raitemId[i],pro_id);
			}
		}
		//삭제후 RA정보식별 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mraasset");
		mv.addObject("reloadPageName",reloadPageName);
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	
	
	//[취약성식별]
	//(취약성식별)
	//취약성식별 페이지로 이동
	public ModelAndView mvlist(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		//검색
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("v_nm",request.getParameter("searchText"));
		}
		List list=riskIService.mvlist(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		//페이지 이동(tiles_definition.xml에서 mvlist_SL을 읽어 다른곳으로 이동
		mv.setViewName("mvlist_SL");
		return mv;
	}
	//취약성식별 엑셀 다운로드 페이지로 이동
	public ModelAndView exmvlist(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		//검색
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("v_nm",request.getParameter("searchText"));
		}
		List list=riskIService.mvlist(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmvlist_SL");
		return mv;
	}	
	//통제 명칭 보여주기
	public void allTsNm(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		int pro_id=Integer.parseInt(request.getParameter("pro_id"));
		MvlistVO vo=riskIService.mvlist_updatePage(request.getParameter("v_id"), pro_id);
		JSONObject obj=new JSONObject();
		obj.put("ts_nm1", vo.getTs_nm1());
		obj.put("ts_nm2", vo.getTs_nm2());
		obj.put("ts_nm3", vo.getTs_nm3());
		obj.put("ts_nm4", vo.getTs_nm4());
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	
	
	
	//취약성식별 수정 페이지로 이동
	public ModelAndView mvlist_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MvlistVO vo=riskIService.mvlist_updatePage(request.getParameter("v_id"), pro_id);
		//system.out.println(vo);
		mv.addObject("vo", vo);
		mv.addObject("update","Y");
		mv.setViewName("mvlist_SU");
		return mv;
	}
	
	// 위협유형 팝업 새창열기
	public ModelAndView openSelectByBaseLev1(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//리스트 값을 얻기전에 base_id의 검색값을 입력
		String base_id=request.getParameter("base_id");
		String base_lev1=request.getParameter("base_lev1");
		TbPublicVO tbvo=new TbPublicVO();
		if(base_lev1==null || base_lev1=="" || base_lev1.equals("")){
		}else{
			tbvo.setBase_lev1(base_lev1);
		}
		tbvo.setBase_id(base_id);
		List vlList=riskIService.tbpublicVLData(tbvo);
		mv.addObject("blist",vlList);
		mv.addObject("base_id",base_id);
		mv.setViewName("openSelectByBaseLev1");
		return mv;
	}
	
	//취약성식별 수정 
	public ModelAndView mvlist_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MvlistVO vo=new MvlistVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("취약성식별 수정값 request값들: "+vo);
		riskIService.mvlist_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mvlist");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	//취약성식별 등록 페이지
	public ModelAndView mvlist_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//최대 순번 구해오기
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String ts_cd1=request.getParameter("ts_cd1");
		String ts_cd2=request.getParameter("ts_cd2");
		String ts_cd3=request.getParameter("ts_cd3");

		MvlistVO vo=new MvlistVO();
		vo.setPro_id(pro_id);
		vo.setTs_cd1(ts_cd1);
		vo.setTs_cd2(ts_cd2);
		vo.setTs_cd3(ts_cd3);
		
		//조회조건
		List distinctList1=riskIService.mvlistDistinct1();
			mv.addObject("distinctList1",distinctList1);
		if(!ts_cd1.equals("0")){	
		List distinctList2=riskIService.mvlistDistinct2(vo);
			mv.addObject("distinctList2",distinctList2);
		}
		if(!ts_cd1.equals("0") && !ts_cd2.equals("0")){	
		List distinctList3=riskIService.mvlistDistinct3(vo);
			mv.addObject("distinctList3",distinctList3);
		}
		List list=riskIService.tbvkind_data(vo);
		//system.out.println(list);
		mv.addObject("list",list);
		mv.addObject("ts_cd1",ts_cd1);
		mv.addObject("ts_cd2",ts_cd2);
		mv.addObject("ts_cd3",ts_cd3);
		mv.setViewName("mvlist_SI");
		return mv;
		/*
		ModelAndView mv=new ModelAndView();
		//최대 순번 구해오기
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		int maxNo=riskIService.maxNo("mvlist_maxNo",pro_id);
		mv.addObject("maxNo",maxNo);
		mv.setViewName("mvlist_SI");
		return mv;
		 */
	}
	
	//취약성식별 등록
	public ModelAndView mvlist_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String ts_cdAll[]=request.getParameterValues("check4");
		String pro_id=request.getParameter("pro_id");
		int proId=Integer.parseInt(pro_id);
		try{
			//체크 박스로 등록
			if(ts_cdAll!=null){
				//체크된 것들의 value값을 받음
				for(int i=0;i<ts_cdAll.length;i++){
					int maxNo=riskIService.maxNo("mvlist_maxNo", proId);
					MvlistVO vo=new MvlistVO();
					vo=riskIService.tbvkind_InsertData(ts_cdAll[i], proId);
					vo.setPro_id(proId);
					vo.setV_id(maxNo);
					//위험식별시나리오 등록
					riskIService.mvlist_insert(vo);
					//traitem_info 등록
				}
			}
			//삭제후 위험식별시나리오 페이지로 이동.
			mv.setViewName("mvlist_insertOK");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResultJsp");
		}
		return mv;
	}
		/*
		ModelAndView mv=new ModelAndView();
		MvlistVO vo=new MvlistVO();
		//vo에 request값들은 담음
		bind(request, vo);
		System.out.println("자산유형분류기준 request값: "+vo);
		try{
			riskIService.mvlist_insert(vo);
			//등록후 list 페이지로 이동
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","mvlist");
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	*/
	//취약성식별  삭제
	public ModelAndView mvlist_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String vId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(vId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<vId.length;i++){
				//system.out.println(vId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.mvlist_delete(vId[i],pro_id);
			}
		}
		//삭제후 취약성식별 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mvlist");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	
	//[위험식별]
	//(위험식별시나리오)
	//위험식별시나리오 페이지로 이동
	public ModelAndView mridenty(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String ascu_id=request.getParameter("ascu_id");
		String asc_id=request.getParameter("asc_id");
		//결과를 리스트에 담음
		List list=null;
		if((ascu_id==null && asc_id==null) || (ascu_id.equals("1") && asc_id.equals("1"))){
			HashMap map=new HashMap();
			map.put("pro_id",pro_id);
			//검색
			if(request.getParameter("searchText")!=null){
				//system.out.println(request.getParameter("searchText"));
				map.put("risk_id",request.getParameter("searchText"));
			}
			list=riskIService.mridenty(map);
		}else{
			//System.out.println("dksdha");
			list=riskIService.mridentySearch(pro_id, ascu_id, asc_id);
		}
		List ascList=riskIService.secretLevel(pro_id);
		List ascuList=riskIService.masecurity(pro_id);
		mv.addObject("ascList",ascList);
		mv.addObject("ascuList",ascuList);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);

		String searchText="";
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			searchText=request.getParameter("searchText");
		}
		//평가된 수
		mv.addObject("pyungCount",riskIService.pyungCount(pro_id,"trisklist","risk_nm", searchText));
		
		//페이지 이동(tiles_definition.xml에서 mridenty_SL을 읽어 다른곳으로 이동
		mv.setViewName("mridenty_SL");
		return mv;
	}
	//위험식별시나리오 엑셀 다운로드 페이지로 이동
	public ModelAndView exmridenty(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		//검색
		if(!request.getParameter("searchText").equals("")){
			//system.out.println(request.getParameter("searchText"));
			//map.put("searchText",request.getParameter("searchText"));
			map.put("risk_id",request.getParameter("searchText"));
		}
		//System.out.println(map);
		//List list=riskIService.mridenty(map);
		List list=riskIService.excelData(map, "mridenty");
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		System.out.println(list);
		mv.addObject("list",list);
		//mv.setViewName("excelDownload");
		mv.setViewName("exmridenty_SL");
		return mv;
	}	
	
	
	
	//위험식별시나리오 등록 페이지
	/*
	public ModelAndView mridenty_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String ascu_id=request.getParameter("ascu_id");
		String asc_id=request.getParameter("asc_id");
		List ascList=riskIService.secretLevel(pro_id);
		List ascuList=riskIService.masecurity(pro_id);
		List list=null;
		int scenarioCount=0;
		if (ascList.size()==0){
			mv.addObject("ascList","N");
			mv.addObject("ascuList",ascuList);
		}else if(ascuList.size()==0){
			mv.addObject("ascList",ascList);
			mv.addObject("ascuList","N");
		}else if(ascList.size()!=0 && ascuList.size()!=0){
			list=riskIService.makeRiskScenario(pro_id,ascu_id,asc_id);
			scenarioCount=riskIService.scenarioCount(pro_id,ascu_id,asc_id);
			mv.addObject("ascList",ascList);
			mv.addObject("ascuList",ascuList);
		}
		//System.out.println(list);
		//system.out.println(scenarioCount);
		mv.addObject("scenarioCount",scenarioCount);
		mv.addObject("list",list);
		mv.setViewName("mridenty_SI");
		return mv;
	}
	*/
	//위험식별시나리오 등록 페이지
	public ModelAndView mridenty_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String ascu_id=request.getParameter("ascu_id");
		String asc_id=request.getParameter("asc_id");
		List ascList=riskIService.secretLevel(pro_id);
		List ascuList=riskIService.masecurity(pro_id);
		String page = request.getParameter("page");
		ListVO lvo=null;
		int scenarioCount=0;
		if (ascList.size()==0){
			mv.addObject("ascList","N");
			mv.addObject("ascuList",ascuList);
		}else if(ascuList.size()==0){
			mv.addObject("ascList",ascList);
			mv.addObject("ascuList","N");
		}else if(ascList.size()!=0 && ascuList.size()!=0){
			if (page == null || page == "")
				page = "1";
			lvo=riskIService.makeRiskScenario(pro_id,ascu_id,asc_id,page);
			scenarioCount=riskIService.scenarioCount(pro_id,ascu_id,asc_id);
			mv.addObject("ascList",ascList);
			mv.addObject("ascuList",ascuList);
		}
		//System.out.println(list);
		//system.out.println(scenarioCount);
		mv.addObject("scenarioCount",scenarioCount);
		mv.addObject("lvo",lvo);
		mv.setViewName("mridenty_SI");
		return mv;
	}
	//위험식별시나리오  등록
	public ModelAndView mridenty_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String hiddenCode[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		String ascu_id=request.getParameter("ascu_id");
		String asc_id=request.getParameter("asc_id");
		int proId=Integer.parseInt(pro_id);
		int ascuId=Integer.parseInt(ascu_id);
		int ascId=Integer.parseInt(asc_id);
		try{
			//체크 박스로 등록
			if(hiddenCode!=null){
				riskIService.mridenty_insertTest(proId,ascuId,ascId,hiddenCode);
				//체크된 것들의 value값을 받음
				//for(int i=0;i<hiddenCodeAndRaitemId.length;i++){
					//String[] str=hiddenCodeAndRaitemId[i].split("\\|");
					//String hiddenCode=str[0];
					//String raitem_id=str[1];
					/*
					String hiddenCode=hiddenCodeAndRaitemId[i];
					//system.out.println(hiddenCode);
					//system.out.println(raitem_id);
					//int maxNo=riskIService.maxNo("mridenty_maxNo", proId);
					RiskScenarioVO rvo=new RiskScenarioVO();
					rvo.setPro_id(proId);
					rvo.setHiddenCode(hiddenCode);
					rvo.setAscu_id(ascuId);
					rvo.setAsc_id(ascId);
					MridentyVO mvo=new MridentyVO();
					mvo=riskIService.makeRiskScenarioData(rvo);

					//system.out.println(mvo);
					//rvo.setRaitem_id(raitem_id);
					String risk_id=riskIService.mridenty_max_risk_id(mvo);
					//system.out.println(risk_id);
					
					//MraassetVO mravo=riskIService.riskScenarioMemo(proId,mvo.getRaitem_id());
					//String cia_memo="기밀성 요구사항 \r\n"+mravo.getC_memo()+"무결성 요구사항 \r\n"+mravo.getI_memo()+"가용성요구사항 \r\n"+mravo.getA_memo();
					//mvo.setCia_memo(cia_memo);
					
					mvo.setRisk_id(risk_id);
					
					//system.out.println(mvo);
					//위험식별시나리오 등록
					riskIService.mridenty_insert(mvo);
					//traitem_info 등록
					 */
					//HashMap map=new HashMap();
					//map.put("pro_id",proId);
					//map.put("ascu_id",ascuId);
					//map.put("asc_id",ascId);
					//map.put("hiddenCode",hiddenCode[i]);
					//riskIService.mridenty_insert(map);
				//}
			}
			//취약성평가_구분별쿼리 (등록)
			riskIService.mavlistp_insert(proId);
			//삭제후 위험식별시나리오 페이지로 이동.
			mv.setViewName("mridenty_insertOK");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResultJsp");
		}
		return mv;
	}
	//위험식별시나리오 수정 페이지로 이동
	public ModelAndView mridenty_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int risk_id=Integer.parseInt(request.getParameter("risk_id"));//서비스단에서 인트로 바꿔줌 
		
		MridentyVO vo=riskIService.mridenty_updatePage(request.getParameter("risk_id"), pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		if(vo!=null){
			MraassetVO mraassetvo=riskIService.mraassetp_updatePage(pro_id, vo.getRaitem_id());
			mv.addObject("mraassetvo", mraassetvo);
			MtlistVO mtvo=riskIService.mtlistData(vo.getTk_id(), pro_id);
			mv.addObject("mtvo", mtvo);
			int mraassetCount=riskIService.mraassetCount(pro_id, vo.getRaitem_id());
			mv.addObject("mraassetCount", mraassetCount);
		}
		
		mv.setViewName("mridenty_SU");
		return mv;
	}
	//위험식별시나리오  삭제
	public ModelAndView mridenty_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String riskId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(riskId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<riskId.length;i++){
				//system.out.println(riskId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.mridenty_delete(riskId[i],pro_id);
			}
		}
		//삭제후 위험식별시나리오 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mridenty");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//위험식별시나리오 수정 
	public ModelAndView mridenty_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MridentyVO vo=new MridentyVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("위험식별시나리오 수정값 request값들: "+vo);
		riskIService.mridenty_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mridenty");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	
	//[취약성평가]
	//(취약성평가)
	//취약성평가 페이지로 이동
	public ModelAndView mvlistp(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.mvlistp(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		mv.addObject("tvchecklistCount",riskIService.tvchecklistCount(pro_id));
		//페이지 이동(tiles_definition.xml에서 mvlist_SL을 읽어 다른곳으로 이동
		mv.setViewName("mvlistp_SL");
		return mv;
	}
	
	//취약성평가 등록 페이지
	public ModelAndView mvlistp_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		String alldata=request.getParameter("alldata");
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		/*
		MvlistVO vo=null;
		if(alldata==null || alldata==""){
			vo=new MvlistVO(0,0,0,0,0,0,0,0,0,0);
		}else if(alldata.equals("Y")){
			vo=new MvlistVO(1,1,1,1,1,1,1,1,1,1);
		}
		vo.setPro_id(pro_id);
		List<String> list2=riskIService.assetListSelectByMraasset(pro_id);
		for(String str:list2){
			if(str.equals("01")){
				vo.setConnA01(1);
			}else if(str.equals("02")){
				vo.setConnA02(1);
			}else if(str.equals("03")){
				vo.setConnA03(1);
			}else if(str.equals("04")){
				vo.setConnA04(1);
			}else if(str.equals("05")){
				vo.setConnA05(1);
			}else if(str.equals("06")){
				vo.setConnA06(1);
			}else if(str.equals("07")){
				vo.setConnA07(1);
			}else if(str.equals("08")){
				vo.setConnA08(1);
			}else if(str.equals("09")){
				vo.setConnA09(1);
			}else if(str.equals("10")){
				vo.setConnA10(1);
			}
		}
		
		//결과를 리스트에 담음
		List list=riskIService.mvlistp_insertPage(vo);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		*/
		//페이지 이동(tiles_definition.xml에서 mvlist_SL을 읽어 다른곳으로 이동
		mv.setViewName("mvlistp_SI");
		return mv;
	}
	
	//취약성평가  등록
	public ModelAndView mvlistp_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		String vId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		int proId=Integer.parseInt(pro_id);
		try{
			//체크 박스로 등록
			if(vId!=null){
				//체크된 것들의 value값을 받음
				for(int i=0;i<vId.length;i++){
					MvlistVO ivo=riskIService.mvlist_updatePage(vId[i],proId);
					//system.out.println(ivo);
					//정보식별 등록
					riskIService.mvlistp_insert(ivo);
					//traitem_info 등록
				}
			}
			//삭제후 취약성평가 페이지로 이동.
			mv.setViewName("mvlistp_insertOK");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResultJsp");
		}
		return mv;
	}
	
	//취약성평가  삭제
	public ModelAndView mvlistp_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String vId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(vId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<vId.length;i++){
				//system.out.println(vId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.mvlist_delete(vId[i],pro_id);//riskIService.mvlistp_delete(vId[i],pro_id);
			}
		}
		//삭제후 취약성평가 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mvlistp");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	//취약성평가 수정 페이지로 이동
	public ModelAndView mvlistp_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MvlistVO vo=riskIService.mvlistp_updatePage(request.getParameter("v_id"), pro_id);
		List vpScoreList=riskIService.tbpublicData("vp_score");
		mv.addObject("vpScoreList",vpScoreList);
		//system.out.println(vo);
		mv.addObject("vo", vo);
		mv.addObject("update","Y");
		mv.setViewName("mvlistp_SU");
		return mv;
	}
	
	//취약성평가 수정 
	public ModelAndView mvlistp_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MvlistVO vo=new MvlistVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("취약성평가 수정값 request값들: "+vo);
		riskIService.mvlistp_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mvlistp");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	
	//(자산공통 취약성 평가)
	//자산공통 취약성 평가 페이지로 이동
	public ModelAndView mavlistp(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		int v_gubun=0;
		if(request.getParameter("v_gubun")!=null){
			v_gubun=Integer.parseInt(request.getParameter("v_gubun"));
		}
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("v_gubun",v_gubun);
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("v_nm",request.getParameter("searchText"));
		}
		
		
		List list=riskIService.mavlistp(map);
		
		String searchText="";
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			searchText=request.getParameter("searchText");
		}
		
		mv.addObject("pyungCount",riskIService.vpyungCount(pro_id,"tvchecklist_ba","vp_kind",v_gubun, searchText));
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		mv.addObject("v_gubun",v_gubun);
		//mv.addObject("tvchecklistCount",riskIService.tvchecklistCount(pro_id));
		//페이지 이동(tiles_definition.xml에서 mavlistp_SL을 읽어 다른곳으로 이동
		mv.setViewName("mavlistp_SL");
		return mv;
		
		
	}
	//자산공통 취약성 엑셀 다운로드 페이지로 이동
	public ModelAndView exmavlistp(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		int v_gubun=0;
		if(request.getParameter("v_gubun")!=null){
			v_gubun=Integer.parseInt(request.getParameter("v_gubun"));
		}
		
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("v_gubun",v_gubun);
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("v_nm",request.getParameter("searchText"));
		}
		
		List list=riskIService.mavlistp(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmavlistp_SL");
		return mv;
	}	
	
	//자산공통 취약성 평가  삭제
	public ModelAndView mavlistp_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String vId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		String v_gubun=request.getParameter("v_gubun");
		//체크 박스로 삭제
		if(vId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<vId.length;i++){
				//system.out.println(vId[i]);
				//삭제
				riskIService.mavlistp_delete(vId[i],pro_id,v_gubun);
			}
		}
		//삭제후 취약성평가 페이지로 이동
		mv.addObject("v_gubun",v_gubun);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mavlistp");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	//연관 자산 갯수 새창열기
	public ModelAndView openMappingMavlistp(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//String raitem_id=request.getParameter("raitem_id");
		String v_gubun=request.getParameter("v_gubun");
		String v_id=request.getParameter("v_id");
		String ts_cd1=request.getParameter("ts_cd1");
		String ts_cd2=request.getParameter("ts_cd2");
		String ts_cd3=request.getParameter("ts_cd3");
		MvlistVO vo=riskIService.mavlistp_updatePage(pro_id, request.getParameter("v_id"), v_gubun);
		mv.addObject("vo", vo);
		//결과를 리스트에 담음
		//system.out.println(v_id);
		List list=riskIService.v_raitem_select(pro_id, ts_cd1, ts_cd2, ts_cd3);
		//system.out.println(list);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("v_gubun",v_gubun);
		//mv.addObject("raitem_id",raitem_id);
		mv.addObject("list",list);
		mv.setViewName("openMappingMavlistp");
		return mv;
	}
	
	//자산공통 취약성평가 수정 페이지로 이동
	public ModelAndView mavlistp_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String v_gubun=request.getParameter("v_gubun");
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MvlistVO vo=riskIService.mavlistp_updatePage(pro_id, request.getParameter("v_id"), v_gubun);
		List vpScoreList=riskIService.tbpublicData("vp_score");
		mv.addObject("vpScoreList",vpScoreList);
		//system.out.println(vo);
		mv.addObject("v_gubun",v_gubun);
		mv.addObject("vo", vo);
		mv.addObject("update","Y");
		mv.setViewName("mavlistp_SI");
		return mv;
	}
	//자산공통 취약성 평가 수정 
	public ModelAndView mavlistp_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MvlistVO vo=new MvlistVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("자산공통 취약성 평가 수정값 request값들: "+vo);
		riskIService.mavlistp_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mavlistp");
		mv.addObject("v_gubun",vo.getV_gubun());
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	
	
	//[보안통제효과성평가]
	//(보안통제효과성평가)
	//보안통제효과성평가 페이지로 이동
	public ModelAndView mbbtlist(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("v_nm",request.getParameter("searchText"));
		}
		
		//결과를 리스트에 담음
		List list=riskIService.mbbtlist(map);
		
		String searchText="";
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			searchText=request.getParameter("searchText");
		}
		mv.addObject("pyungCount",riskIService.pyungCount(pro_id,"tvchecklist_ba","vp_kind",searchText));
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		//페이지 이동(tiles_definition.xml에서 mbbtlist_SL을 읽어 다른곳으로 이동
		mv.setViewName("mbbtlist_SL");
		return mv;
	}
	//보안통제효과성평가 엑셀 다운로드 페이지로 이동
	public ModelAndView exmbbtlist(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("v_nm",request.getParameter("searchText"));
		}
		List list=riskIService.mbbtlist(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmbbtlist_SL");
		return mv;
	}	
	//보안통제효과성평가 수정 페이지로 이동
	public ModelAndView mbbtlist_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		String v_gubun=request.getParameter("v_gubun");
		MvlistVO vo=riskIService.mavlistp_updatePage(pro_id, request.getParameter("v_id"), v_gubun);
		List vpScoreList=riskIService.tbpublicData("vp_score");
		mv.addObject("vpScoreList",vpScoreList);
		//system.out.println(vo);
		mv.addObject("vo", vo);
		mv.addObject("v_gubun",v_gubun);
		mv.addObject("update","Y");
		mv.setViewName("mbbtlist_SI");
		return mv;
	}
	//보안통제효과성평가 수정 
	public ModelAndView mbbtlist_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MvlistVO vo=new MvlistVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("보안통제효과성평가 수정값 request값들: "+vo);
		riskIService.mbbtlist_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mbbtlist");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//보안통제효과성평가  삭제
	public ModelAndView mbbtlist_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String vIdAndVgubun[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(vIdAndVgubun!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<vIdAndVgubun.length;i++){
				//system.out.println(vIdAndVgubun[i]);
				String[] str=vIdAndVgubun[i].split("\\|");
				String v_id=str[0];
				String v_gubun=str[1];
				//system.out.println(v_id);
				//system.out.println(v_gubun);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.mavlistp_delete(v_id,pro_id,v_gubun);
			}
		}
		//삭제후 보안통제효과성평가 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mbbtlist");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	

	
	
	//[위험수준산정]
	//(취약성점수 산정기준)
	//취약성점수 산정기준 페이지로 이동
	public ModelAndView mvscore(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.mvscore(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		
		/*
		//DOA기준설정
		List rbList=riskIService.tbpublicData("rb_score");
		mv.addObject("rbList",rbList);
		List vlList=riskIService.tbpublicDataDesc("vl_level");
		mv.addObject("vlList",vlList);
		List akList=riskIService.tbpublicData("ak_score");
		mv.addObject("akList",akList);
		
		
		//low 척도, high 척도 
		TbPublicVO rbvo=(TbPublicVO) rbList.get(rbList.size()-1);
		TbPublicVO vlvo=(TbPublicVO) vlList.get(vlList.size()-1);
		TbPublicVO akvo=(TbPublicVO) akList.get(akList.size()-1);
		int riskdegree=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int exChangeRD=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt()*1.67);
		mv.addObject("riskdegree",riskdegree);
		mv.addObject("exChangeRD",exChangeRD);
		
		
		//위험등급 결정 기준(DoA)
		List tdoa;
		tdoa=riskIService.tdoa(pro_id);
		if(tdoa.size()==0){
			tdoa=riskIService.tdoa_base();
		}
		mv.addObject("tdoa",tdoa);
		
		String flagPop=request.getParameter("flagPop");
		if(flagPop!=null && flagPop.equals("Y")){
			//mv.addObject("flagPop",flagPop);
			mv.setViewName("open_mrlevel_SL");
		}else{
			mv.setViewName("mvscore_SL");
		}
		*/
		mv.setViewName("mvscore_SL");
		return mv;
	}
	//취약성점수 산정기준 등록 페이지
	public ModelAndView mvscore_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//최대 순번 구해오기
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		int maxNo=riskIService.maxNo("mvscore_maxNo",pro_id);
		mv.addObject("maxNo",maxNo);
		mv.setViewName("mvscore_SI");
		return mv;
	}
	//취약성점수 산정기준 등록
	public ModelAndView mvscore_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MvscoreVO vo=new MvscoreVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("취약성점수 산정기준 request값: "+vo);
		try{
			riskIService.mvscore_insert(vo);
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","mvscore");
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	//취약성점수 산정기준  삭제
	public ModelAndView mvscore_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String vpId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(vpId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<vpId.length;i++){
				//system.out.println(vpId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.mvscore_delete(vpId[i],pro_id);
			}
		}
		//삭제후 취약성점수 산정기준 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mvscore");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//자산보안등급평가기준 수정 페이지로 이동
	public ModelAndView mvscore_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		MvscoreVO vo=riskIService.mvscore_updatePage(request.getParameter("vp_id"),pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		mv.setViewName("mvscore_SI");
		return mv;
	}
	//취약성점수 산정기준 수정 
	public ModelAndView mvscore_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MvscoreVO vo=new MvscoreVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("취약성점수 산정기준 수정값 request값들: "+vo);
		riskIService.mvscore_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mvscore");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	
	//취약성 등급 ajax
	public void onloadVscore(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		//float 타입으로 캐스팅
		int pro_id=Integer.parseInt(request.getParameter("pro_id"));
		float vp_total=Float.parseFloat(request.getParameter("vp_total"));
		JSONObject obj=new JSONObject();
		//자산 중요도 평가 정보를 부름
		List mvlist=riskIService.mvscore(pro_id);
		if(mvlist.size()!=0){
			for (int i = 0;i<mvlist.size();i++){
				MvscoreVO vo=(MvscoreVO)mvlist.get(i);
				float vs_score=vo.getVs_score();
				float vl_score=vo.getVl_score();
				//받아온 데이터가 시작보다 크거나 같고, 나중값+1 보다 작을때
				//if(sScore<=assetScore && assetScore<(lScore+1)){
				if(vs_score<=vp_total && vp_total<=(vl_score)){
					//System.out.println(vo.getImpo_kind());
					//자산등급을 적어줌
					obj.put("vp_id", vo.getVp_id());
					obj.put("v_level",vo.getV_level());
					TbPublicVO tbvo=riskIService.tbpublicDataVlLevel(vo.getVp_id());
					obj.put("v_score", tbvo.getBase_cnt());
				}
			}
		}else{
			obj.put("vp_id","N");
			obj.put("v_level","N");
		}
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}	
	

	//[위험수준평가]
	//(평가기준수립)
	//평가기준수립 페이지로 이동
	public ModelAndView mrlevel(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		List rbList=riskIService.tbpublicData("rb_score");
		mv.addObject("rbList",rbList);
		List vlList=riskIService.tbpublicDataDesc("vl_level");
		mv.addObject("vlList",vlList);
		List akList=riskIService.tbpublicData("ak_score");
		mv.addObject("akList",akList);
		
		
		//low 척도, high 척도 
		TbPublicVO rbvo=(TbPublicVO) rbList.get(rbList.size()-1);
		TbPublicVO vlvo=(TbPublicVO) vlList.get(vlList.size()-1);
		TbPublicVO akvo=(TbPublicVO) akList.get(akList.size()-1);
		int riskdegree=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int exChangeRD=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt()*1.67);
		mv.addObject("riskdegree",riskdegree);
		mv.addObject("exChangeRD",exChangeRD);
		
		
		//위험등급 결정 기준(DoA)
		List tdoa;
		tdoa=riskIService.tdoa(pro_id);
		if(tdoa.size()==0){
			tdoa=riskIService.tdoa_base();
		}
		mv.addObject("tdoa",tdoa);
		/*
		//위험등급 결정 기준
		TbPublicVO rbvo1=(TbPublicVO) rbList.get(rbList.size()-3);
		TbPublicVO rbvo2=(TbPublicVO) rbList.get(rbList.size()-4);
		int highRiskCount=(int) (rbvo1.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int midRiskCount=(int) (rbvo2.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		mv.addObject("rbDoAHigh",(int)rbvo1.getBase_cnt());
		mv.addObject("rbDoALow",(int)rbvo2.getBase_cnt());
		mv.addObject("vlDoA",(int)vlvo.getBase_cnt());
		mv.addObject("akDoA",(int)akvo.getBase_cnt());
		mv.addObject("highRiskCount",highRiskCount);
		mv.addObject("midRiskCount",midRiskCount);
		*/
		String flagPop=request.getParameter("flagPop");
		if(flagPop!=null && flagPop.equals("Y")){
			//mv.addObject("flagPop",flagPop);
			mv.setViewName("open_mrlevel_SL");
		}else{
			mv.setViewName("mrlevel_SL");
		}
		
		return mv;
	}
	
	//위험등급 결정 기준(DoA) 등록
	public ModelAndView DoA_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//팝업 유무 조사
		String flagPop=request.getParameter("flagPop");
		String reloadPageName=request.getParameter("reloadPageName");
		//----------------
		TdoaVO voLow=new TdoaVO();
		TdoaVO voHigh=new TdoaVO();
		ArrayList<TdoaVO> list=new ArrayList<TdoaVO>(); 
		voLow.setPro_id(Integer.parseInt(request.getParameter("pro_id")));
		voLow.setDoa_gubun(1);
		voLow.setRiskb_score(Integer.parseInt(request.getParameter("riskb_score_L")));
		voLow.setV_score(Integer.parseInt(request.getParameter("v_score_L")));
		voLow.setSy_score(Integer.parseInt(request.getParameter("sy_score_L")));
		voLow.setDoa_score(Integer.parseInt(request.getParameter("lowDoA_score")));
		 list.add(voLow);
		//system.out.println("위험등급 DoA low 값: "+voLow);
		
		voHigh.setPro_id(Integer.parseInt(request.getParameter("pro_id")));
		voHigh.setDoa_gubun(2);
		voHigh.setRiskb_score(Integer.parseInt(request.getParameter("riskb_score_H")));
		voHigh.setV_score(Integer.parseInt(request.getParameter("v_score_H")));
		voHigh.setSy_score(Integer.parseInt(request.getParameter("sy_score_H")));
		voHigh.setDoa_score(Integer.parseInt(request.getParameter("highDoA_score")));
		 list.add(voHigh);
		//system.out.println("위험등급 DoA high 값: "+voHigh);
		
		//system.out.println("리스트값:"+list);
		try{
			//리스트에 담아서 service단에서 나누어서 insert 함
			riskIService.DoA_insert(list);
			if(flagPop==""){
				mv.addObject("pageName","mrlevel");
				mv.setViewName("insertAndDeleteResult");
			}else if(flagPop.equals("Y")){
				mv.addObject("reloadPageName",reloadPageName);
				mv.setViewName("DoA_insertOK");
			}
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResultJsp");
		}
		return mv;
	}
	
	
	//평가기준수립 등록 페이지
	public ModelAndView mrlevel_insertPage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		List rbList=riskIService.tbpublicData("rb_score");
		mv.addObject("rbList",rbList);
		List vlList=riskIService.tbpublicDataDesc("vl_level");
		mv.addObject("vlList",vlList);
		List akList=riskIService.tbpublicData("ak_score");
		mv.addObject("akList",akList);
		mv.setViewName("mrlevel_SI");
		return mv;
	}
	//평가기준수립 등록
	public ModelAndView mrlevel_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//name값으로 위협발생 가능성, 점수 받음
		String rbBaseNm[]=request.getParameterValues("rbBaseNm");
		String rbBaseCnt[]=request.getParameterValues("rbBaseCnt");
		String base_id=null;
		if(rbBaseCnt!=null && rbBaseNm!=null){
			for(int i=0;i<rbBaseCnt.length;i++){
				base_id="rb_score";
				String base_lev1="0"+(i+1);
				riskIService.mrlevel_insert(base_id, base_lev1, rbBaseNm[i], rbBaseCnt[i]);
			}
		}
		//name값으로 취약성 등급, 점수 받음
		String vlBaseNm[]=request.getParameterValues("vlBaseNm");
		String vlBaseCnt[]=request.getParameterValues("vlBaseCnt");
		if(vlBaseCnt!=null && vlBaseNm!=null){
			for(int i=0;i<vlBaseCnt.length;i++){
				base_id="vl_level";
				String base_lev1=null;
				for(int j=vlBaseCnt.length;j>0;j--){
					base_lev1 = String.valueOf(j);
					//system.out.println(base_lev1);
				}
				riskIService.mrlevel_insert(base_id, base_lev1, vlBaseNm[i], vlBaseCnt[i]);
			}
		}
		//name값으로 사업 영향도, 점수 받음
		String akBaseNm[]=request.getParameterValues("akBaseNm");
		String akBaseCnt[]=request.getParameterValues("akBaseCnt");
		if(akBaseCnt!=null && akBaseNm!=null){
			for(int i=0;i<akBaseCnt.length;i++){
				base_id="ak_score";
				String base_lev1="0"+(i+1);
				riskIService.mrlevel_insert(base_id, base_lev1, akBaseNm[i], akBaseCnt[i]);
			}
		}
		//삭제후 평가기준수립 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mrlevel");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	//(위험수준산정)
	//위험수준산정 페이지로 이동
	public ModelAndView mrscore(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("risk_id",request.getParameter("searchText"));
		}
		
		
		List list=riskIService.mrscore(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		
		
		String searchText="";
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			searchText=request.getParameter("searchText");
		}
		//평가된 수
		mv.addObject("pyungCount",riskIService.pyungCount(pro_id,"trisklist","risk_imm",searchText));
		
		//위험등급 결정 기준(DoA)
		List tdoa;
		tdoa=riskIService.tdoa(pro_id);
		if(tdoa.size()==0){
			tdoa=riskIService.tdoa_base();
		}
		mv.addObject("tdoa",tdoa);
		//페이지 이동(tiles_definition.xml에서 mridenty_SL을 읽어 다른곳으로 이동
		mv.setViewName("mrscore_SL");
		return mv;
	}

	//위험수준산정 엑셀 다운로드 페이지로 이동
	public ModelAndView exmrscore(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		if(!request.getParameter("searchText").equals("")){
			//system.out.println(request.getParameter("searchText"));
			map.put("risk_id",request.getParameter("searchText"));
		}
		//List list=riskIService.mrscore(map);
		List list=riskIService.excelData(map,"mrscore");
		System.out.println(list);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		mv.setViewName("exmrscore_SL");
		return mv;
	}	
	
	//위험 수준 산정 및 평가 정보 팝업
	public ModelAndView openTriskCal(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String risk_id=request.getParameter("risk_id");
		//위험 수준 산정 및 평가 정보
		TtriskcalcVO calvo=riskIService.mrscore_updatePageCal(pro_id, risk_id);
		mv.addObject("calvo",calvo);
		
		//위험수준 산정에 필요한 점수들
		List rbList=riskIService.tbpublicData("rb_score");
		mv.addObject("rbList",rbList);
		List vlList=riskIService.tbpublicDataDesc("vl_level");
		mv.addObject("vlList",vlList);
		List akList=riskIService.tbpublicData("ak_score");
		mv.addObject("akList",akList);
		MridentyVO vo=riskIService.mrscore_updatePage(request.getParameter("risk_id"), pro_id);
		mv.addObject("vo", vo);
		MraassetVO mraassetvo=riskIService.mraassetp_updatePage(pro_id, vo.getRaitem_id());
		mv.addObject("mraassetvo", mraassetvo);
		//점수 최대치
		TbPublicVO rbvo=(TbPublicVO) rbList.get(rbList.size()-1);
		TbPublicVO vlvo=(TbPublicVO) vlList.get(vlList.size()-1);
		TbPublicVO akvo=(TbPublicVO) akList.get(akList.size()-1);
		int rvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int chRvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt()*1.67);
		mv.addObject("rvatotal",rvatotal);
		mv.addObject("chRvatotal",chRvatotal);
		//페이지 이동(tiles_definition.xml에서 mridenty_SL을 읽어 다른곳으로 이동
		mv.setViewName("openTriskCal");
		return mv;
	}
	
	
	//위험수준산정 수정 페이지로 이동
	public ModelAndView mrscore_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int risk_id=Integer.parseInt(request.getParameter("risk_id"));//서비스단에서 인트로 바꿔줌 

		MridentyVO vo=riskIService.mrscore_updatePage(request.getParameter("risk_id"), pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		if(vo!=null){
			MraassetVO mraassetvo=riskIService.mraassetp_updatePage(pro_id, vo.getRaitem_id());
			TtriskcalcVO calvo=riskIService.mrscore_updatePageCal(pro_id, vo.getRisk_id());
			mv.addObject("mraassetvo", mraassetvo);
			MtlistVO mtvo=riskIService.mtlistData(vo.getTk_id(), pro_id);
			mv.addObject("mtvo", mtvo);
			mv.addObject("calvo",calvo);
			int mraassetCount=riskIService.mraassetCount(pro_id, vo.getRaitem_id());
			mv.addObject("mraassetCount", mraassetCount);
		}
		//tbpublic 점수값들
		List rbList=riskIService.tbpublicData("rb_score");
		mv.addObject("rbList",rbList);
		List vlList=riskIService.tbpublicDataDesc("vl_level");
		mv.addObject("vlList",vlList);
		List akList=riskIService.tbpublicData("ak_score");
		//점수 최대치
		TbPublicVO rbvo=(TbPublicVO) rbList.get(rbList.size()-1);
		TbPublicVO vlvo=(TbPublicVO) vlList.get(vlList.size()-1);
		TbPublicVO akvo=(TbPublicVO) akList.get(akList.size()-1);
		int rvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int chRvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt()*1.67);
		mv.addObject("rvatotal",rvatotal);
		mv.addObject("chRvatotal",chRvatotal);
		
		//위험등급 결정 기준
		TbPublicVO rbvo1=(TbPublicVO) rbList.get(rbList.size()-3);
		TbPublicVO rbvo2=(TbPublicVO) rbList.get(rbList.size()-4);
		int highRiskCount=(int) (rbvo1.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int midRiskCount=(int) (rbvo2.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		mv.addObject("highRiskCount",highRiskCount);
		mv.addObject("midRiskCount",midRiskCount);
		
		
		//위험등급 결정 기준(DoA)
		List tdoa;
		tdoa=riskIService.tdoa(pro_id);
		if(tdoa.size()==0){
			tdoa=riskIService.tdoa_base();
		}
		mv.addObject("tdoa",tdoa);
		
		//리스트
		List mvsclist=riskIService.mvscoreDesc(pro_id);
		mv.addObject("mvsclist",mvsclist);
		mv.setViewName("mrscore_SI");
		return mv;
	}
	
	//위험수준산정 계산 테이블 등록
	public ModelAndView mrscore_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//system.out.println(request.getParameter("riskb_poss"));
		TtriskcalcVO vo=new TtriskcalcVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("위험수준산정 산정기준 request값: "+vo);
		try{
			riskIService.mrscore_insert(vo);
			//if(vo.getRisk_imm()!=0){
			riskIService.mrscore_insert1(vo);
			//}
		}catch (SQLException e) {//SQL에러시
			riskIService.mrscore_update(vo);
			//if(vo.getRisk_imm()!=0){
				//try{
				//	riskIService.mrscore_insert1(vo);
				//}catch (SQLException e1) {//SQL에러시
					riskIService.mrscore_update1(vo);
				//}
			//}
		}
		mv.addObject("pageName","mrscore");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//위험수준산정  삭제
	public ModelAndView mrscore_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String riskId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(riskId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<riskId.length;i++){
				//system.out.println(riskId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.mridenty_delete(riskId[i],pro_id);
			}
		}
		//삭제후 위험수준산정 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mrscore");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	//[위험처리계획수립]
	//(위험처리방안선정)
	//위험처리방안선정 페이지로 이동
	public ModelAndView mridenty3(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("risk_id",request.getParameter("searchText"));
		}
		List list=riskIService.mridenty3(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		
		
		//평가된 수
		String searchText="";
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			searchText=request.getParameter("searchText");
		}
		mv.addObject("pyungCount",riskIService.pyungCount(pro_id,"trisklist","treat_state",searchText));
		//위험등급 결정 기준(DoA)
		List tdoa;
		tdoa=riskIService.tdoa(pro_id);
		if(tdoa.size()==0){
			tdoa=riskIService.tdoa_base();
		}
		mv.addObject("tdoa",tdoa);
		//페이지 이동(tiles_definition.xml에서 mridenty_SL을 읽어 다른곳으로 이동
		mv.setViewName("mridenty3_SL");
		return mv;
	}
	
	//위험처리방안선정 엑셀 다운로드 페이지로 이동
	public ModelAndView exmridenty3(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		if(!request.getParameter("searchText").equals("")){
			//system.out.println(request.getParameter("searchText"));
			map.put("risk_id",request.getParameter("searchText"));
		}
		//List list=riskIService.mrscore(map);
		List list=riskIService.excelData(map,"mridenty3");
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmridenty3_SL");
		return mv;
	}	
	
	//위험처리방안선정팝업
	public ModelAndView openTriskplan(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String risk_id=request.getParameter("risk_id");
		//위험 수준 산정 및 평가 정보
		TtriskcalcVO calvo=riskIService.mrscore_updatePageCal(pro_id, risk_id);
		mv.addObject("calvo",calvo);
		//위험처리방안선정 정보
		mv.addObject("tplanvo",riskIService.mridenty3_updatePage(pro_id, risk_id));
		
		//위험수준 산정에 필요한 점수들
		List rbList=riskIService.tbpublicData("rb_score");
		mv.addObject("rbList",rbList);
		List vlList=riskIService.tbpublicDataDesc("vl_level");
		mv.addObject("vlList",vlList);
		List akList=riskIService.tbpublicData("ak_score");
		mv.addObject("akList",akList);
		MridentyVO vo=riskIService.mrscore_updatePage(request.getParameter("risk_id"), pro_id);
		mv.addObject("vo", vo);
		MraassetVO mraassetvo=riskIService.mraassetp_updatePage(pro_id, vo.getRaitem_id());
		mv.addObject("mraassetvo", mraassetvo);
		//점수 최대치
		TbPublicVO rbvo=(TbPublicVO) rbList.get(rbList.size()-1);
		TbPublicVO vlvo=(TbPublicVO) vlList.get(vlList.size()-1);
		TbPublicVO akvo=(TbPublicVO) akList.get(akList.size()-1);
		int rvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int chRvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt()*1.67);
		mv.addObject("rvatotal",rvatotal);
		mv.addObject("chRvatotal",chRvatotal);
		//페이지 이동(tiles_definition.xml에서 mridenty_SL을 읽어 다른곳으로 이동
		mv.setViewName("openTriskplan");
		return mv;
	}
	
	//위험처리방안선정 수정 페이지로 이동
	public ModelAndView mridenty3_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int risk_id=Integer.parseInt(request.getParameter("risk_id"));//서비스단에서 인트로 바꿔줌 

		MridentyVO vo=riskIService.mrscore_updatePage(request.getParameter("risk_id"), pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		if(vo!=null){
			MraassetVO mraassetvo=riskIService.mraassetp_updatePage(pro_id, vo.getRaitem_id());
			TtriskcalcVO calvo=riskIService.mrscore_updatePageCal(pro_id, vo.getRisk_id());
			mv.addObject("mraassetvo", mraassetvo);
			MtlistVO mtvo=riskIService.mtlistData(vo.getTk_id(), pro_id);
			mv.addObject("mtvo", mtvo);
			mv.addObject("calvo",calvo);
			mv.addObject("tplanvo",riskIService.mridenty3_updatePage(pro_id, vo.getRisk_id()));
			int mraassetCount=riskIService.mraassetCount(pro_id, vo.getRaitem_id());
			mv.addObject("mraassetCount", mraassetCount);
		}
		//tbpublic 점수값들
		List rbList=riskIService.tbpublicData("rb_score");
		mv.addObject("rbList",rbList);
		List vlList=riskIService.tbpublicDataDesc("vl_level");
		mv.addObject("vlList",vlList);
		List akList=riskIService.tbpublicData("ak_score");
		//점수 최대치
		TbPublicVO rbvo=(TbPublicVO) rbList.get(rbList.size()-1);
		TbPublicVO vlvo=(TbPublicVO) vlList.get(vlList.size()-1);
		TbPublicVO akvo=(TbPublicVO) akList.get(akList.size()-1);
		int rvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int chRvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt()*1.67);
		mv.addObject("rvatotal",rvatotal);
		mv.addObject("chRvatotal",chRvatotal);
		
		/*
		//위험등급 결정 기준
		TbPublicVO rbvo1=(TbPublicVO) rbList.get(rbList.size()-3);
		TbPublicVO rbvo2=(TbPublicVO) rbList.get(rbList.size()-4);
		int highRiskCount=(int) (rbvo1.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int midRiskCount=(int) (rbvo2.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		mv.addObject("highRiskCount",highRiskCount);
		mv.addObject("midRiskCount",midRiskCount);
		*/
		//위험등급 결정 기준(DoA)
		List tdoa;
		tdoa=riskIService.tdoa(pro_id);
		if(tdoa.size()==0){
			tdoa=riskIService.tdoa_base();
		}
		mv.addObject("tdoa",tdoa);
		
		//리스트
		List mvsclist=riskIService.mvscoreDesc(pro_id);
		mv.addObject("mvsclist",mvsclist);

		//final_renew_day 오늘날짜 (tplanvo가 없을때만 뿌려줄꺼임)
		String nowDate=today.getDateString("yyyy.MM.dd");
		mv.addObject("nowDate",nowDate);
		
		mv.setViewName("mridenty3_SI");
		return mv;
	}
	
	
	//위험처리방안선정 계산 테이블 등록
	public ModelAndView mridenty3_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		TriskplanVO vo=new TriskplanVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("위험처리방안선정 request값: "+vo);
		
		try{
			riskIService.mridenty3_insert(vo);
		}catch (SQLException e) {//SQL에러시
			riskIService.mridenty3_update(vo);
		}
		
		mv.addObject("pageName","mridenty3");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//위험처리방안선정  삭제
	public ModelAndView mridenty3_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String riskId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(riskId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<riskId.length;i++){
				//system.out.println(riskId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.mridenty_delete(riskId[i],pro_id);
			}
		}
		//삭제후 위험수준산정 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mridenty3");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	
	
	
	//(자산위협매트릭스)
	//자산위협매트릭스 페이지로 이동
	public ModelAndView atmetrix(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.makind(pro_id);
		HashMap map=new HashMap();
		ArrayList<MakindVO> listMap=riskIService.makindMap(pro_id);
		map.put("listMap",listMap);
		map.put("pro_id",pro_id);
		//system.out.println(list);
		//system.out.println(listMap);
		//List metList=riskIService.atmetrix(pro_id, map);
		List metList=riskIService.atmetrix(pro_id, listMap);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		//system.out.println("나온값:"+metList);
		mv.addObject("metList",metList);
		
		
		/*
		//위협 취약성 매트릭스
		
		//결과를 리스트에 담음
		HashMap mapz=new HashMap();
		mapz.put("pro_id",pro_id);
		//System.out.println("pro_id:"+pro_id);
		//System.out.println("mapz:"+mapz);
		//검색
		//List list1=riskIService.mtkind(mapz);
		//HashMap map1=new HashMap();
		ArrayList<MtkindVO> listMap1=riskIService.mtkindArrayList(mapz);
		//map.put("listMap",listMap1);
		//map.put("pro_id",pro_id);
		//system.out.println("list1:"+list1);
		//system.out.println("listMap1:"+listMap1);
		//List metList=riskIService.atmetrix(pro_id, map);
		List metList1=riskIService.tvmetrix(pro_id, listMap1);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list1",listMap1);
		//system.out.println("나온값:"+metList1);
		mv.addObject("metList1",metList1);
		*/
		/*
		//받아올 이름을 받기위해 만든 list
		ArrayList nameList=new ArrayList();
			for(int i=0; i<metList.size();i++){
			String akName;
			for(int j=0;j<4;j++){ 
					for(int k=1;k<100;k++){
						if(k<10){
							akName="ak_id"+j+"00"+k;
						}else{
							akName="ak_id"+j+"0"+k;
						}
						nameList.add(akName);
					}
				}
			}
			////system.out.println(nameList);
			mv.addObject("nameList",nameList);
			*/
		//페이지 이동(tiles_definition.xml에서 atmetrix_SL을 읽어 다른곳으로 이동
		mv.setViewName("atmetrix_SL");
		return mv;
	}
	//자산위협매트릭스 등록
	public void insertAtmetrix(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		JSONObject obj=new JSONObject();
		int pro_id=Integer.parseInt(request.getParameter("pro_id"));
		String ak_id=request.getParameter("ak_id");
		String base_lev1=request.getParameter("base_lev1");
		String base_lev2=request.getParameter("base_lev2");
		String base_lev3=request.getParameter("base_lev3");
		int at_value=Integer.parseInt(request.getParameter("at_value"));
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("ak_id",ak_id);
		map.put("base_lev1",base_lev1);
		map.put("base_lev2",base_lev2);
		map.put("base_lev3",base_lev3);
		map.put("at_value",at_value);

		try{
			riskIService.insertAtmetrix(map);
			obj.put("insertFlag","Y");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			obj.put("insertFlag","N");
		}
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}

	//자산위협매트릭스 삭제
	public void deleteAtmetrix(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		JSONObject obj=new JSONObject();
		int pro_id=Integer.parseInt(request.getParameter("pro_id"));
		String ak_id=request.getParameter("ak_id");
		String base_lev1=request.getParameter("base_lev1");
		String base_lev2=request.getParameter("base_lev2");
		String base_lev3=request.getParameter("base_lev3");
		int at_value=Integer.parseInt(request.getParameter("at_value"));
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("ak_id",ak_id);
		map.put("base_lev1",base_lev1);
		map.put("base_lev2",base_lev2);
		map.put("base_lev3",base_lev3);
		map.put("at_value",at_value);

		try{
			riskIService.deleteAtmetrix(map);
			obj.put("deleteFlag","Y");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			obj.put("deleteFlag","N");
		}
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	
	
	
	//(위험취약성매트릭스)
	//위험취약성매트릭스 페이지로 이동
	public ModelAndView tvmetrix(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		
		//결과를 리스트에 담음
		//HashMap mapz=new HashMap();
		//mapz.put("pro_id",pro_id);
	
		//List list=riskIService.mtkind(mapz);
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		ArrayList<MtkindVO> listMap=riskIService.mtkindArrayList(map);
		//map.put("listMap",listMap);
		//map.put("pro_id",pro_id);
		//system.out.println(list);
		//system.out.println(listMap);
		//List metList=riskIService.atmetrix(pro_id, map);
		List metList=riskIService.tvmetrix(pro_id, listMap);
		//리스트라는 객체에 list를 담아 보냄(request.setAttribute와 동일)
		mv.addObject("list",listMap);
		//system.out.println("나온값:"+metList);
		mv.addObject("metList",metList);
		
		/*
		//받아올 이름을 받기위해 만든 list
		ArrayList nameList=new ArrayList();
			for(int i=0; i<metList.size();i++){
			String akName;
			for(int j=0;j<4;j++){ 
					for(int k=1;k<100;k++){
						if(k<10){
							akName="ak_id"+j+"00"+k;
						}else{
							akName="ak_id"+j+"0"+k;
						}
						nameList.add(akName);
					}
				}
			}
			//System.out.println(nameList);
			mv.addObject("nameList",nameList);
			*/
		//페이지 이동(tiles_definition.xml에서 atmetrix_SL을 읽어 다른곳으로 이동
		mv.setViewName("tvmetrix_SL");
		return mv;
	}
	
	//위험취약성매트릭스 등록
	public void insertTvmetrix(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		JSONObject obj=new JSONObject();
		int pro_id=Integer.parseInt(request.getParameter("pro_id"));
		String tk_id=request.getParameter("tk_id");
		String base_lev1=tk_id.substring(0,2);
		String base_lev2=tk_id.substring(2,4);
		String base_lev3=tk_id.substring(4,6);
		String ts_cd1=request.getParameter("ts_cd1");
		String ts_cd2=request.getParameter("ts_cd2");
		String ts_cd3=request.getParameter("ts_cd3");
		String ts_cd4=request.getParameter("ts_cd4");
		int tv_value=Integer.parseInt(request.getParameter("tv_value"));
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("tk_id",tk_id);
		map.put("base_lev1",base_lev1);
		map.put("base_lev2",base_lev2);
		map.put("base_lev3",base_lev3);
		map.put("ts_cd1",ts_cd1);
		map.put("ts_cd2",ts_cd2);
		map.put("ts_cd3",ts_cd3);
		map.put("ts_cd4",ts_cd4);
		map.put("tv_value",tv_value);
		try{
			riskIService.insertTvmetrix(map);
			obj.put("insertFlag","Y");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			obj.put("insertFlag","N");
		}
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}

	//위험취약성매트릭스 삭제
	public void deleteTvmetrix(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		JSONObject obj=new JSONObject();
		int pro_id=Integer.parseInt(request.getParameter("pro_id"));
		String tk_id=request.getParameter("tk_id");
		String base_lev1=tk_id.substring(0,2);
		String base_lev2=tk_id.substring(2,4);
		String base_lev3=tk_id.substring(4,6);
		String ts_cd1=request.getParameter("ts_cd1");
		String ts_cd2=request.getParameter("ts_cd2");
		String ts_cd3=request.getParameter("ts_cd3");
		String ts_cd4=request.getParameter("ts_cd4");
		int tv_value=Integer.parseInt(request.getParameter("tv_value"));
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("tk_id",tk_id);
		map.put("base_lev1",base_lev1);
		map.put("base_lev2",base_lev2);
		map.put("base_lev3",base_lev3);
		map.put("ts_cd1",ts_cd1);
		map.put("ts_cd2",ts_cd2);
		map.put("ts_cd3",ts_cd3);
		map.put("ts_cd4",ts_cd4);
		map.put("tv_value",tv_value);
		try{
			riskIService.deleteTvmetrix(map);
			obj.put("deleteFlag","Y");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			obj.put("deleteFlag","N");
		}
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}
	
	
	
	
	//[위험수용]
	//(잔여위험평가)
	//잔여위험평가 페이지로 이동
	public ModelAndView mridenty4(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			map.put("risk_id",request.getParameter("searchText"));
		}
		List list=riskIService.mridenty4(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		//평가된 수
		String searchText="";
		if(request.getParameter("searchText")!=null){
			//system.out.println(request.getParameter("searchText"));
			searchText=request.getParameter("searchText");
		}
		mv.addObject("pyungCount",riskIService.pyungCount(pro_id,"trisklist","doa_yn",searchText));
		//위험등급 결정 기준(DoA)
		List tdoa;
		tdoa=riskIService.tdoa(pro_id);
		if(tdoa.size()==0){
			tdoa=riskIService.tdoa_base();
		}
		mv.addObject("tdoa",tdoa);
		
		//페이지 이동(tiles_definition.xml에서 mridenty_SL을 읽어 다른곳으로 이동
		mv.setViewName("mridenty4_SL");
		return mv;
	}
	
	//잔여위험평가 엑셀 다운로드 페이지로 이동
	public ModelAndView exmridenty4(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		if(!request.getParameter("searchText").equals("")){
			//system.out.println(request.getParameter("searchText"));
			map.put("risk_id",request.getParameter("searchText"));
		}
		//List list=riskIService.mridenty4(map);
		List list=riskIService.excelData(map,"mridenty4");
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.setViewName("exmridenty4_SL");
		return mv;
	}	
	//잔여위험평가 팝업
	public ModelAndView openTrerisk(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		String risk_id=request.getParameter("risk_id");
		//위험 수준 산정 및 평가 정보
		TtriskcalcVO calvo=riskIService.mrscore_updatePageCal(pro_id, risk_id);
		mv.addObject("calvo",calvo);
		//위험처리방안선정 정보
		mv.addObject("tplanvo",riskIService.mridenty3_updatePage(pro_id, risk_id));
		mv.addObject("trevo",riskIService.mridenty4_updatePage(pro_id, risk_id));
		//위험수준 산정에 필요한 점수들
		List rbList=riskIService.tbpublicData("rb_score");
		mv.addObject("rbList",rbList);
		List vlList=riskIService.tbpublicDataDesc("vl_level");
		mv.addObject("vlList",vlList);
		List akList=riskIService.tbpublicData("ak_score");
		mv.addObject("akList",akList);
		MridentyVO vo=riskIService.mrscore_updatePage(request.getParameter("risk_id"), pro_id);
		mv.addObject("vo", vo);
		MraassetVO mraassetvo=riskIService.mraassetp_updatePage(pro_id, vo.getRaitem_id());
		mv.addObject("mraassetvo", mraassetvo);
		//점수 최대치
		TbPublicVO rbvo=(TbPublicVO) rbList.get(rbList.size()-1);
		TbPublicVO vlvo=(TbPublicVO) vlList.get(vlList.size()-1);
		TbPublicVO akvo=(TbPublicVO) akList.get(akList.size()-1);
		int rvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int chRvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt()*1.67);
		mv.addObject("rvatotal",rvatotal);
		mv.addObject("chRvatotal",chRvatotal);
		//페이지 이동(tiles_definition.xml에서 mridenty_SL을 읽어 다른곳으로 이동
		mv.setViewName("openTrerisk");
		return mv;
	}
	
	
	//잔여위험평가 수정 페이지로 이동
	public ModelAndView mridenty4_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//int risk_id=Integer.parseInt(request.getParameter("risk_id"));//서비스단에서 인트로 바꿔줌 

		MridentyVO vo=riskIService.mrscore_updatePage(request.getParameter("risk_id"), pro_id);
		//system.out.println(vo);
		mv.addObject("update","Y");
		mv.addObject("vo", vo);
		if(vo!=null){
			MraassetVO mraassetvo=riskIService.mraassetp_updatePage(pro_id, vo.getRaitem_id());
			TtriskcalcVO calvo=riskIService.mrscore_updatePageCal(pro_id, vo.getRisk_id());
			mv.addObject("mraassetvo", mraassetvo);
			MtlistVO mtvo=riskIService.mtlistData(vo.getTk_id(), pro_id);
			mv.addObject("mtvo", mtvo);
			mv.addObject("calvo",calvo);
			mv.addObject("tplanvo",riskIService.mridenty3_updatePage(pro_id, vo.getRisk_id()));
			mv.addObject("trevo",riskIService.mridenty4_updatePage(pro_id, vo.getRisk_id()));
			int mraassetCount=riskIService.mraassetCount(pro_id, vo.getRaitem_id());
			mv.addObject("mraassetCount", mraassetCount);
		}
		//tbpublic 점수값들
		List rbList=riskIService.tbpublicData("rb_score");
		mv.addObject("rbList",rbList);
		List vlList=riskIService.tbpublicDataDesc("vl_level");
		mv.addObject("vlList",vlList);
		List akList=riskIService.tbpublicData("ak_score");
		//점수 최대치
		TbPublicVO rbvo=(TbPublicVO) rbList.get(rbList.size()-1);
		TbPublicVO vlvo=(TbPublicVO) vlList.get(vlList.size()-1);
		TbPublicVO akvo=(TbPublicVO) akList.get(akList.size()-1);
		int rvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int chRvatotal=(int) (rbvo.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt()*1.67);
		mv.addObject("rvatotal",rvatotal);
		mv.addObject("chRvatotal",chRvatotal);
		
		/*
		//위험등급 결정 기준
		TbPublicVO rbvo1=(TbPublicVO) rbList.get(rbList.size()-3);
		TbPublicVO rbvo2=(TbPublicVO) rbList.get(rbList.size()-4);
		int highRiskCount=(int) (rbvo1.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		int midRiskCount=(int) (rbvo2.getBase_cnt()*vlvo.getBase_cnt()*akvo.getBase_cnt());
		mv.addObject("highRiskCount",highRiskCount);
		mv.addObject("midRiskCount",midRiskCount);
		*/
		
		//위험등급 결정 기준(DoA)
		List tdoa;
		tdoa=riskIService.tdoa(pro_id);
		if(tdoa.size()==0){
			tdoa=riskIService.tdoa_base();
		}
		mv.addObject("tdoa",tdoa);
		
		//리스트
		List mvsclist=riskIService.mvscoreDesc(pro_id);
		mv.addObject("mvsclist",mvsclist);
		
		//final_renew_day 오늘날짜 (tplanvo가 없을때만 뿌려줄꺼임)
		String nowDate=today.getDateString("yyyy.MM.dd");
		mv.addObject("nowDate",nowDate);
		
		mv.setViewName("mridenty4_SI");
		return mv;
	}
	
	//잔여위험평가 계산 테이블 등록
	public ModelAndView mridenty4_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		TreriskVO vo=new TreriskVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("위험처리방안선정 request값: "+vo);
		
		try{
			riskIService.mridenty4_insert(vo);
		}catch (SQLException e) {//SQL에러시
			riskIService.mridenty4_update(vo);
		}
		
		mv.addObject("pageName","mridenty4");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//잔여위험평가  삭제
	public ModelAndView mridenty4_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String riskId[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(riskId!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<riskId.length;i++){
				//system.out.println(riskId[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.mridenty_delete(riskId[i],pro_id);
			}
		}
		//삭제후 위험수준산정 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","mridenty4");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	//[SoA정립]
	//(SoA정립)
	//SoA정립 페이지로 이동
	public ModelAndView msoa(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		List list=riskIService.msoa(pro_id);
		//tsoa에 들어있는 데이터인지 확인하기 위한 리스트
		
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		List flagList=riskIService.tsoaData(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		mv.addObject("list",list);
		mv.addObject("flagList",flagList);
		//system.out.println(flagList);
		//페이지 이동(tiles_definition.xml에서 msoa_SL을 읽어 다른곳으로 이동
		mv.setViewName("msoa_SL");
		return mv;
	}
	
	//SoA정립 엑셀 다운로드 페이지로 이동
	public ModelAndView exmsoa(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		//결과를 리스트에 담음
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		List list=riskIService.excelData(map,"msoa");
		List flagList=riskIService.tsoaData(map);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//system.out.println(list);
		mv.addObject("list",list);
		mv.addObject("flagList",flagList);
		mv.setViewName("exmsoa_SL");
		return mv;
	}	
	//SoA정립 수정 페이지로 이동
	public ModelAndView msoa_updatePage(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		//회차 정보
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}

		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("tsAll",request.getParameter("tsAll"));
		List flagList=riskIService.tsoaData(map);
		if(flagList.size()==0){
			mv.addObject("vo", riskIService.msoa_insertPage(map));
		}else{
			mv.addObject("vo", riskIService.msoa_updatePage(map));
			mv.addObject("update","Y");
		}
		//int job_no=Integer.parseInt(request.getParameter("job_no"));//서비스단에서 인트로 바꿔줌 
		//MtlistVO vo=riskIService.msoa_updatePage(request.getParameter("risk_id"), pro_id);
		mv.setViewName("msoa_SI");
		return mv;
	}
	
	//SoA정립 등록
	public ModelAndView msoa_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MsoaVO vo=new MsoaVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("SoA정립 request값: "+vo);
		try{
			riskIService.msoa_insert(vo);
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","msoa");
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	
	
	//SoA정립 수정 
	public ModelAndView msoa_update(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		MsoaVO vo=new MsoaVO();
		//vo에 request값들은 담음
		bind(request, vo);
		//system.out.println("SoA정립 수정값 request값들: "+vo);
		riskIService.msoa_update(vo);
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","msoa");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	//SoA정립 삭제
	public ModelAndView msoa_delete(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String tsAll[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		if(tsAll!=null){
			//체크된 것들의 value값을 받음
			for(int i=0;i<tsAll.length;i++){
				//system.out.println(tsAll[i]);
				//삭제
				//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
				riskIService.msoa_delete(tsAll[i],pro_id);
			}
		}
		//삭제후 취약성점수 산정기준 페이지로 이동
		mv.addObject("actionName",actionName);
		mv.addObject("pageName","msoa");
		mv.setViewName("insertAndDeleteResult");
		return mv;
	}
	
	
	//SoA정립 list페이지에서 insert
	public ModelAndView msoa_SL_insert(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		String tsAll[]=request.getParameterValues("check");
		String pro_id=request.getParameter("pro_id");
		//체크 박스로 삭제
		try{
			if(tsAll!=null){
				//체크된 것들의 value값을 받음
				for(int i=0;i<tsAll.length;i++){
					//system.out.println(tsAll[i]);
					//삭제
					//int job_no=Integer.parseInt(jobNo[i]); //서비스단에서 인트로 바꿔줌 
					HashMap map=new HashMap();
					map.put("pro_id",pro_id);
					map.put("tsAll",tsAll[i]);
					List flagList=riskIService.tsoaData(map);
					if(flagList.size()==0){
						riskIService.msoa_SL_insert(riskIService.msoa_insertPage(map));
					}
				}
			}
			//삭제후 취약성점수 산정기준 페이지로 이동
			mv.addObject("actionName",actionName);
			mv.addObject("pageName","msoa");
			mv.setViewName("insertAndDeleteResult");
		}catch (SQLException e) {//SQL에러시
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}
		return mv;
	}
	
	
	
	
	//[현황관리]
	//(현황관리)
	//현황관리 검색 페이지로 이동
	public ModelAndView stateReport(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		
		int pro_id=0;
		String pro_loginID="";
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		
		if(session!=null && session.getAttribute("USER_ID")!=null){
			pro_loginID=(String)session.getAttribute("USER_ID");
		}
		
		session.removeAttribute("StateReportVO"); 
		//프로젝트 iap버전
		List projectList=projectService.mplist(pro_loginID);
		mv.addObject("projectList",projectList);
		
		//지역/사이트
		List siteList=riskIService.siteList(pro_id);
		mv.addObject("siteList",siteList);
		
		//프로세스
		List procList=riskIService.procList(pro_id);
		mv.addObject("procList",procList);
		
		//자산유형
		List makindList=riskIService.makind(pro_id);
		mv.addObject("makindList",makindList);

		//보안등급
		List ascuList=riskIService.masecurity(pro_id);
		mv.addObject("ascuList",ascuList);
		
		//기밀등급
		List ascList=riskIService.masecret(pro_id);
		mv.addObject("ascList",ascList);
		
		//보안 통제 영역 값
		List ts_nm2List=riskIService.ts_nm2List(pro_id);
		mv.addObject("ts_nm2List",ts_nm2List);
		
		//보안 통제 항목 값
		List ts_nm3List=riskIService.ts_nm3List(pro_id, "0");
		//system.out.println(ts_nm3List);
		mv.addObject("ts_nm3List",ts_nm3List);
		/*
		mv.addObject("",);
		mv.addObject("",);
		mv.addObject("",);
		mv.addObject("",);
		*/
		//페이지 이동(tiles_definition.xml에서 mbbtlist_SL을 읽어 다른곳으로 이동
		mv.setViewName("stateReport_SP");
		return mv;
	}
	//보안 통제 항목 값(Ajax)
	public void ts_nm3ListAjax(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		//자산코드의 값을 UTF-8로 인코딩하여 받음
		int pro_id = Integer.parseInt(request.getParameter("pro_id"));
		String ts_nm2= request.getParameter("ts_nm2");
		JSONObject obj=new JSONObject();
		JSONArray arr=new JSONArray();
			//boolean rainfo_idFlag = riskIService.searchRainfoId(rainfo_id,pro_id);
		List ts_nm3List=riskIService.ts_nm3List(pro_id, ts_nm2);
		obj.put("ts_nm3List",ViewUtil.ts_nm3ListSelectBox(ts_nm3List));
				
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}	
	//현황관리 페이지로 이동
	public ModelAndView stateReport_SL(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		//회차를 받아서 조회
		HttpSession session = request.getSession(false);
		int pro_id=0;
		String pro_loginID="";
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
			
		}
		if(session!=null && session.getAttribute("USER_ID")!=null){
			pro_loginID=(String)session.getAttribute("USER_ID");
		}
		//system.out.println("vo|"+session.getAttribute("StateReportVO"));
		StateReportVO vo=null;
		if(session!=null && session.getAttribute("StateReportVO")!=null){
			vo=(StateReportVO)session.getAttribute("StateReportVO");
			session.removeAttribute("StateReportVO"); 
		}
		//결과를 리스트에 담음
		//List list=riskIService.makind(pro_id);
		//리스트라는 객체에 list를 담아 보넴(request.setAttribute와 동일)
		//mv.addObject("list",list);
		//페이지 이동(tiles_definition.xml에서 makind_SL을 읽어 다른곳으로 이동
		int searchCondition=1;
		if(vo!=null && vo.getSearchCondition()!=1){
			searchCondition=vo.getSearchCondition();
		}
		//system.out.println("넘어온값:"+vo);
		if(vo!=null){
			vo.setPro_loginID(pro_loginID);
			List list=riskIService.stateReportResult(vo);
			//system.out.println(list);
			mv.addObject("list",list);
			System.out.println(list);
			mv.addObject("vo",vo);
		}else{
			StateReportVO fvo=new StateReportVO();
			fvo.setPro_loginID(pro_loginID);
			fvo.setPro_id(pro_id);
			fvo.setSearchCondition(searchCondition);
			fvo.setRainfo_site("0");
			fvo.setRainfo_proc("0");
			List list=riskIService.stateReportResult(fvo);
			//System.out.println(list);
			mv.addObject("list",list);
			mv.addObject("vo",fvo);
		}
		//mv.addObject("list",list);
		mv.addObject("searchCondition",searchCondition);
		System.out.println("뭐가 문제");
		mv.setViewName("stateReport_SL");
		return mv;
	}
	
	//현황관리 조회 결과 바인딩후 넘길 페이지
	public ModelAndView stateReport_searchOK(HttpServletRequest request,HttpServletResponse response) throws Exception{
		ModelAndView mv=new ModelAndView();
		StateReportVO vo=new StateReportVO();
		bind(request, vo);
		//system.out.println("현황관리 바인딩 값: "+vo);
		mv.addObject("StateReportVO",vo);
		mv.setViewName("stateReport_searchOK");
		return mv;
	}
	

	
	//엑셀 업로드
	public ModelAndView excelUpload(HttpServletRequest request,HttpServletResponse response, Object command) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		savedir=request.getSession().getServletContext().getRealPath("/");
		//system.out.println(savedir);
		String filename="";
		String originalFilename="";
		String reloadPageName="";
		Map map=new HashMap();
		//try{
		//파일 업로드
		MultipartRequest multi=new MultipartRequest(request, savedir, sizeLimit, "UTF-8", new DefaultFileRenamePolicy());
		Enumeration files = multi.getFileNames(); // 폼의 이름 반환
	      while (files.hasMoreElements()) {
	        String name = (String)files.nextElement(); // 자료가 많을 경우엔 while 문을 사용
	        filename = multi.getFilesystemName(name);// 파일업로드한 이름 얻기
	        originalFilename = multi.getOriginalFileName(name);//파일 진짜 이름
	       // String type = multi.getContentType(name); //전송된 파일의 내용 타입
	        File f = multi.getFile(name);
	      }
	      String fn=originalFilename.toLowerCase();
	  	  String ext=fn.substring(fn.lastIndexOf(".")+1);
	      //system.out.println(ext);
	      reloadPageName=multi.getParameter("reloadPageName");
	    //vo.setTitle(multi.getParameter("title"));
			//vo.setContent(multi.getParameter("content"));
			//vo.setId(id);
	      
	      map=riskIService.excelUpload(pro_id, ext, savedir, filename, reloadPageName);
	      
	      if(map.get("errorCode").equals("")){
	    	  mv.addObject("actionName",actionName);
	  	    if(reloadPageName.equals("mrainfoCon")){
	  	    	mv.addObject("pageName","mrainfo#tabs-2");
	  	    }else{
	  	    	mv.addObject("pageName",reloadPageName);
	  	    }
	  	  mv.setViewName("insertAndDeleteResult");
	      }else{
	    	  if(reloadPageName.equals("mrainfoCon")){
	    		  mv.addObject("pageName",reloadPageName);
	    	  }
	    	  mv.addObject("errorCode", map.get("errorCode"));
	    	  deleteFile(savedir,filename); //파일 삭제
			  mv.setViewName("failResult");
	      }
	    
		
		
	     // File fs = new File(savedir+filename);
		//	fs.delete();
		//}catch(Exception ex){
			//TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
			//System.out.println(ex.getMessage());
			/*
			Iterator it=map.keySet().iterator();
			while(it.hasNext()){
				String key=it.next().toString();
				//system.out.println("key:"+key+" value:"+map.get(key));
				if(reloadPageName.equals("mrainfoCon")){
					if(key.equals("cell2")){
						mv.addObject("errorCode", map.get(key));
					}
				}else{
					if(key.equals("cell1")){
						mv.addObject("errorCode", map.get(key));
					}
				}
				
			}
			*/
			//deleteFile(savedir,filename); //파일 삭제
			//mv.setViewName("failResult");
		//}
		
		try{
			deleteFile(savedir,filename); //파일 삭제
		}catch(SecurityException sec){
			System.out.println("Excel Upload Error:"+sec);
		}
		return mv;
	}
	
	
	
	
	
	
	
	/*예전 소스
	//엑셀 업로드
	public ModelAndView excelUpload(HttpServletRequest request,HttpServletResponse response, Object command) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		ModelAndView mv=new ModelAndView();
		HttpSession session = request.getSession(false);
		int pro_id=0;
		if(session!=null && session.getAttribute("lastProId")!=null){
			pro_id=(Integer) session.getAttribute("lastProId");
		}
		savedir=request.getSession().getServletContext().getRealPath("/");
		//system.out.println(savedir);
		String filename="";
		String originalFilename="";
		String reloadPageName="";
		HashMap map=new HashMap();
		try{
		//파일 업로드
		MultipartRequest multi=new MultipartRequest(request, savedir, sizeLimit, "UTF-8", new DefaultFileRenamePolicy());
		Enumeration files = multi.getFileNames(); // 폼의 이름 반환
	      while (files.hasMoreElements()) {
	        String name = (String)files.nextElement(); // 자료가 많을 경우엔 while 문을 사용
	        filename = multi.getFilesystemName(name);// 파일업로드한 이름 얻기
	        originalFilename = multi.getOriginalFileName(name);//파일 진짜 이름
	       // String type = multi.getContentType(name); //전송된 파일의 내용 타입
	        File f = multi.getFile(name);
	      }
	      String fn=originalFilename.toLowerCase();
	  	  String ext=fn.substring(fn.lastIndexOf(".")+1);
	      //system.out.println(ext);
	      reloadPageName=multi.getParameter("reloadPageName");
	    //vo.setTitle(multi.getParameter("title"));
			//vo.setContent(multi.getParameter("content"));
			//vo.setId(id);
	      if(ext.equals("xls")){
	    	  //poi 엑셀 관련
		      POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream(savedir+filename));
	          HSSFWorkbook wb=new HSSFWorkbook(fs);
	          int sheetNum=wb.getNumberOfSheets(); //시트갯수 가져오기

	          for(int i=0; i<sheetNum; i++){
	        	  HSSFSheet sheet=wb.getSheetAt(i); //시트 가져오기
	        	  
	              int rows=sheet.getPhysicalNumberOfRows(); //행 갯수 가져오기
	              //for(int j=0; j<rows; j++){ //row 루프
	              for(int j=1; j<rows; j++){ //row 루프 // 1행은 제목줄
	                  HSSFRow row=sheet.getRow(j); //row 가져오기
	                  if(row!=null){
	                	  
	                      int cells=row.getPhysicalNumberOfCells(); //cell 갯수 가져오기
	                      for(short c=0; c<cells; c++){ //cell 루프
	                          HSSFCell cell=row.getCell(c); //cell 가져오기
	                          if(cell!=null){
	                              String value=null;
	                              switch(cell.getCellType()){ //cell 타입에 따른 데이타 저장
	                                  case HSSFCell.CELL_TYPE_FORMULA:
	                                      value=cell.getCellFormula();
	                                      System.out.println("어디서");
	                                      break;
	                                  case HSSFCell.CELL_TYPE_NUMERIC:
	                                	  if (HSSFDateUtil.isCellDateFormatted(cell)){
	                                		  SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd"); 
	                                          value=""+formatter.format(cell.getDateCellValue());
	                                     } else{
	                                    	 value=""+(int)cell.getNumericCellValue();
	                                     }
	                                	  System.out.println("나는지");
	                                      break;
	                                  case HSSFCell.CELL_TYPE_STRING:
	                                      value=""+cell.getStringCellValue();
	                                      System.out.println("찾아");
	                                      break;
	                                  case HSSFCell.CELL_TYPE_BLANK:
	                                      value=""+cell.getBooleanCellValue();
	                                	  //value=""+cell.getStringCellValue();
	                                      System.out.println("봅시다");
	                                      break;
	                                  case HSSFCell.CELL_TYPE_ERROR:
	                                      value=""+cell.getErrorCellValue();
	                                      System.out.println("왜나?");
	                                      break;
	                                  default:
	                              }
	                              //system.out.println("cell:"+(cell.getColumnIndex()+1)+", value:"+value);
	                              //stat.setString(count, value); //쿼리문 값 대입
	                              
	                              //system.out.println("cell:"+(cell.getColumnIndex()+1)+", value:"+value);
		                             //System.out.println("| 2 : "+cell.getCellType()); //셀의 타입인듯
		                              //System.out.println("| 7 : "+cell.getRawValue()); // 계속적인 숫자 증가
		                              //System.out.println("| 8 : "+cell.getReference()); // 엑셀 위치?(A, 2 같은거)
		                              //System.out.println("| 9 : "+cell.getRowIndex()); // 줄 순번(0번째줄, 1번째줄)
		                              //stat.setString(count, value); //쿼리문 값 대입
	                              map.put("cell"+(cell.getColumnIndex()+1), value);
	                          }
	                      }
	                      //stat.executeUpdate(); //쿼리문 insert 실행
	                  }
	                  map.put("cell0", pro_id);
	                  System.out.println(map);
	                  if(reloadPageName.equals("mrainfo")){
	                	  riskIService.mrainfo_insertExcel(map);
	                  }else if(reloadPageName.equals("mrainfoCon")){
	                	  riskIService.tracont_insertExcel(map);
	                  }else if(reloadPageName.equals("mraasset")){
	                	  //riskIService.mraasset_insertExcel(map);
	                  }
	                  //맵 초기화
	                  map=new HashMap();
	              }
	          }
	      }else if(ext.equals("xlsx")){
	    	  //poi 엑셀 관련
	    	  XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(new File(savedir+filename)));
	          int sheetNum=wb.getNumberOfSheets(); //시트갯수 가져오기

	          for(int i=0; i<sheetNum; i++){
	        	  XSSFSheet sheet=wb.getSheetAt(i); //시트 가져오기
	        	  
	              int rows=sheet.getPhysicalNumberOfRows(); //행 갯수 가져오기
	              //for(int j=0; j<rows; j++){ //row 루프
	              for(int j=1; j<rows; j++){ //row 루프 // 1행은 제목줄
	                  XSSFRow row=sheet.getRow(j); //row 가져오기
	                  if(row!=null){
	                	  
	                      int cells=row.getPhysicalNumberOfCells(); //cell 갯수 가져오기
	                      for(short c=0; c<cells; c++){ //cell 루프
	                          XSSFCell cell=row.getCell(c); //cell 가져오기
	                          if(cell!=null){
	                              String value=null;
	                              switch(cell.getCellType()){ //cell 타입에 따른 데이타 저장
	                                  case XSSFCell.CELL_TYPE_FORMULA:
	                                      value=cell.getCellFormula();
	                                      break;
	                                  case XSSFCell.CELL_TYPE_NUMERIC:
	                                	  if (HSSFDateUtil.isCellDateFormatted(cell)){
	                                		  SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd"); 
	                                          value=""+formatter.format(cell.getDateCellValue());
	                                     } else{
	                                    	 value=""+(int)cell.getNumericCellValue();
	                                     }
	                                      break;
	                                  case XSSFCell.CELL_TYPE_STRING:
	                                      value=""+cell.getStringCellValue();
	                                      break;
	                                  case XSSFCell.CELL_TYPE_BLANK:
	                                	  //value=""+cell.getStringCellValue();
	                                      value=""+cell.getBooleanCellValue();
	                                      break;
	                                  case XSSFCell.CELL_TYPE_ERROR:
	                                      value=""+cell.getErrorCellValue();
	                                      break;
	                                  default:
	                              }
	                              //system.out.println("cell:"+(cell.getColumnIndex()+1)+", value:"+value);
	                             //system.out.println("| 2 : "+cell.getCellType()); //셀의 타입인듯
	                              //System.out.println("| 7 : "+cell.getRawValue()); // 계속적인 숫자 증가
	                              //System.out.println("| 8 : "+cell.getReference()); // 엑셀 위치?(A, 2 같은거)
	                              //System.out.println("| 9 : "+cell.getRowIndex()); // 줄 순번(0번째줄, 1번째줄)
	                              //stat.setString(count, value); //쿼리문 값 대입
	                              map.put("cell"+(cell.getColumnIndex()+1), value);
	                          }
	                      }
	                      //stat.executeUpdate(); //쿼리문 insert 실행
	                  }
	                  map.put("cell0", pro_id);
	                  System.out.println(map);
	                  if(reloadPageName.equals("mrainfo")){
	                	  riskIService.mrainfo_insertExcel(map);
	                  }else if(reloadPageName.equals("mrainfoCon")){
	                	  riskIService.tracont_insertExcel(map);
	                  }else if(reloadPageName.equals("mraasset")){
	                	  //riskIService.mraasset_insertExcel(map);
	                  }
	                  //맵 초기화
	                  map=new HashMap();
	              }
	          }
	      }
	      
	    mv.addObject("actionName",actionName);
	    if(reloadPageName.equals("mrainfoCon")){
	    	mv.addObject("pageName","mrainfo");
	    }else{
	    	mv.addObject("pageName",reloadPageName);
	    }
		
		mv.setViewName("insertAndDeleteResult");
	     // File fs = new File(savedir+filename);
		//	fs.delete();
		}catch(IOException e){
			deleteFile(savedir,filename); //파일 삭제
			System.out.println(e.getMessage());
			mv.setViewName("failResult");
		}catch(Exception ex){
			//TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
			System.out.println(ex.getMessage());
			Iterator it=map.keySet().iterator();
			while(it.hasNext()){
				String key=it.next().toString();
				//system.out.println("key:"+key+" value:"+map.get(key));
				if(reloadPageName.equals("mrainfoCon")){
					if(key.equals("cell2")){
						mv.addObject("errorCode", map.get(key));
					}
				}else{
					if(key.equals("cell1")){
						mv.addObject("errorCode", map.get(key));
					}
				}
				
			}
			deleteFile(savedir,filename); //파일 삭제
			mv.setViewName("failResult");
		}
		
		try{
			deleteFile(savedir,filename); //파일 삭제
		}catch(SecurityException sec){
			System.out.println("Excel Upload Error:"+sec);
		}
		return mv;
	}
	*/
	
	
	
	
	
	
	
	
	
	
	
	
	//디렉토리 만들기
	public void makeDir(String savedir) throws Exception{
		java.io.File dir=new java.io.File(savedir);
		if(!dir.exists()){	dir.mkdirs();	}
	}
	public void deleteFile(String savedir, String filename) throws Exception{
		File fs = new File(savedir+filename);
		fs.delete();
	}
	
	
	
	
	
	
	//컨테이너 클릭 이벤트(값 세팅)
	public void setContInfoAjax(HttpServletRequest request,HttpServletResponse response) throws Exception{
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		//자산코드의 값을 UTF-8로 인코딩하여 받음
		String racont_nm= request.getParameter("racont_nm");
		String base_lev1=request.getParameter("base_lev1");
		String pro_id=request.getParameter("pro_id");
		//system.out.println(rainfo_id);
		JSONObject obj=new JSONObject();
		JSONArray arr=new JSONArray();
			boolean tracont2Flag = riskIService.tracont2Flag(pro_id, racont_nm, base_lev1);
			if (tracont2Flag) {// racont_nm가 있으면
				//flag가 Y 면 전체 체크
				obj.put("tracont2Flag", "Y");
			
				} else {// racont_nm가  없으면
				obj.put("tracont2Flag", "N");
				//flag가 N면 부분 체크(rainfo_id)값을 받아온다
				
				List list=riskIService.rainfoIDSelect(pro_id, racont_nm, base_lev1);
				arr.addAll(list);
				obj.put("list", arr);
			}
			obj.put("racont_nm", racont_nm);
			obj.put("base_lev1", base_lev1);
		PrintWriter out = response.getWriter();
		out.print(obj.toString());
	}	
}